Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

System specs and code sample in the end of this contribution!

First of all, I am new to this forum. Please tell me if there is anything wrong with the layout or the question itself. I am also new to linux, ubuntu and kind of a newbie at java. I was using windows 7 before ubuntu. The problem appeared first after installing ubuntu on my machine.

Problem

When running animation windows in eclipse, using the swing package or java applet - the animation is jumpy and not smooth. I will show you a sample from my code of a very simple program that consists of a JPanel and a JFrame with a background and a 2d-ball moving from left to right. The program is set to repaint every 30 ms. It shouldn't be a problem to run simple graphics like this. Eclipse is fast and smooth otherwise. Would appreciate any help or advice, if someone has encountered something like this before!

What i tried

*searching for bugs or problems related to this, but not finding any

*Installing the latest versions of Eclipse and the latest JDK

*Editing my eclipse.ini file

*running my code on My Windows 7 machine (Works fine)

*installing bumblebee and using nvidia optimus

System

OS: Ubuntu 12.04 (precise) 64-bit

Memory: 5.6 GiB, Processor intel Core 2.5 GHz x 4 CPU

Eclipse Juno 4.2.0

java version brings me

$ -java version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

my eclipse.ini file

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120913-144807
 -product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs

-Xincgc

-XX:NewSize=8m
-XX:MaxPermHeapExpansion=10m
-XX:CMSInitiatingOccupancyFraction=70
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+UseParNewGC
-XX:+CMSConcurrentMTEnabled
-XX:ConcGCThreads=2
-XX:ParallelGCThreads=2
-XX:CMSIncrementalDutyCycleMin=0
-XX:CMSIncrementalDutyCycle=5
-XX:GCTimeRatio=49
-XX:MaxGCPauseMillis=20
-XX:GCPauseIntervalMillis=1000
-XX:+UseCMSCompactAtFullCollection
-XX:+CMSClassUnloadingEnabled
-XX:+DoEscapeAnalysis
-XX:+UseCompressedOops
-XX:+AggressiveOpts
-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses

-Dosgi.requiredJavaVersion=1.7
-Dhelp.lucene.tokenizer=standard
-XX:MaxPermSize=128m
-XX:PermSize=128m
-Xmn128m
-Xms1024m
-Xmx1024m
-Xss2m
-XX:+UseConcMarkSweepGC

Code sample

/////////Sample from the JPanel class /////////

private int y = 200;
private int x = 0;

public testPanel() {
setVisible(true);
setPreferredSize(new Dimension(1500,400));
setBackground(Color.black);
}

public void move() {
x = x+2;
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.green);
g.fillOval(x,y,50,50);
}
}

///////Sample from the JFrame class /////////

private testPanel thePanel = new testPanel();
private Timer t = new Timer(30,this);



public testFrame() {
add(thePanel);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
t.start();

}

public void actionPerformed(ActionEvent e) {
thePanel.move();
repaint();
}

Edit: Adding an exception: When i hover with my mouse ( and keep moving it ) over the application window the animation stops beeing jumpy. when i stop moving, it starts beeing not smooth and jumpy again. Anyone heard of this?

share|improve this question
    
First off, the layout is great! Secondly: do you have any Graphics driver installed? Because currently it might be rendered on your CPU which makes it jumpy. –  BeryJu May 10 '13 at 15:52
    
if i run lspci | grep VGA i get VGA compatible controller: Intel Corporation Ivy Bridge Graphics Controller (rev 09) –  luzy May 11 '13 at 7:34
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.