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.

I got downvoted on StackOverflow so I turn to you to see if I can get any help. I have a problem I have spent so much time trying to solve, but so far in vain.

I am using eclipse juno server realease 2 with recently installed ubuntu 12.04. When running the simplest swing or applet applications, the animation is not smooth and very slow. CPU and memory remains the same though. Though, when I move my mouse over the running frame or applet the animation becomes smooth and nice, and when I stop moving my mouse it becomes slow again which I don't understand at all. I have run the same programs on windows 7 on the same computer and it worked without problems, so I know its not the hardware... I have tried updated my drivers and I am running eclipse of my nvidia optimus.

Specs:

Ubuntu 12.04 64 bit
Memory 5.6 GiB
Processor: Intel core i5-3210M CPU @ 2.5 gHzx4

Anyone encountered this problem?

Sample code of what I'm trying to do:

//A simple program with a frame and a panel

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;


public class testPanel2 extends JPanel{

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

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

public void move() {
    x++;
    repaint();
}

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

//Frame: 

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.Timer;


 public class testFrame2 extends JFrame implements ActionListener {

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

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

}

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

public static void main(String[] args) {
    new testFrame2();
}

}
share|improve this question
add comment

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.