Problem with focus setting of Ubuntu windows when using Java [closed]

4

I was doing a program where a circle is drawn on the screen and it moves around the screen, using the JFrame classes to create the window, a thread to control the circle that I enter on the screen. >

The problem however is when I run my program, because when running on my Operating System (Ubuntu 14.04) the circle seems to be locked while it is being redrawn by the screen, however when moving the mouse inside the program the circle is redesigned perfectly. When tested on another OS the program will work perfectly.

I wonder if anyone has any idea what I could do, either with regard to my OS or my application.

Here are the codes of my circle class that implements Runnable:

public class Circulo extends JComponent implements Runnable{

private Desenho desenhoCirculo = null;
private int velocidadeCirculo_x;
private int velocidadeCirculo_y;
private Color corCirculo;
private ColisaoCirculo colisao;

public Circulo(Desenho desenhoCirculo, int velocidadeCirculo_x, int velocidadeCirculo_y, Color corCirculo, ColisaoCirculo colisao) {
    this.desenhoCirculo = desenhoCirculo;
    this.velocidadeCirculo_x = velocidadeCirculo_x;
    this.velocidadeCirculo_y = velocidadeCirculo_y;
    this.corCirculo = corCirculo;
    this.colisao = colisao;
    new Thread(this).start();
}

public void mexerCirculo( int x, int y ){
    this.desenhoCirculo.setPos_x( this.desenhoCirculo.getPos_x() + x);
    this.desenhoCirculo.setPos_y( this.desenhoCirculo.getPos_y() + y);
}

public Desenho getDesenhoCirculo() {
    return desenhoCirculo;
}

public void setDesenhoCirculo(Desenho desenhoCirculo) {
    this.desenhoCirculo = desenhoCirculo;
}

public int getVelocidadeCirculo_x() {
    return velocidadeCirculo_x;
}

public void setVelocidadeCirculo_x(int velocidadeCirculo_x) {
    this.velocidadeCirculo_x = velocidadeCirculo_x;
}

public int getVelocidadeCirculo_y() {
    return velocidadeCirculo_y;
}

public void setVelocidadeCirculo_y(int velocidadeCirculo_y) {
    this.velocidadeCirculo_y = velocidadeCirculo_y;
}

public Color getCorCirculo() {
    return corCirculo;
}

public void setCorCirculo(Color corCirculo) {
    this.corCirculo = corCirculo;
}

public ColisaoCirculo getColisao() {
    return colisao;
}

public void setColisao(ColisaoCirculo colisao) {
    this.colisao = colisao;
}



@Override
public void paint( Graphics g ){
    g.setColor(corCirculo);
    g.fillOval(desenhoCirculo.getPos_x(), desenhoCirculo.getPos_y(), desenhoCirculo.getLargura(), desenhoCirculo.getAltura());
}

@Override
public void run() {
    while( true ){
        try {
            Thread.sleep(20);
            this.mexerCirculo( this.velocidadeCirculo_x, this.velocidadeCirculo_y );
            this.colisao.checarColisaoComLimitesTela( this );
            repaint();

        } catch (InterruptedException ex) {
            Logger.getLogger(Circulo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

}

    
asked by anonymous 03.07.2014 / 14:00

0 answers