0
Javaアニメーションのちらつきをなくしたい
改めて質問させていただきます。下記のJavaアニメーションのちらつきをなくしたいのですがどうすればいいでしょうか?教えてください。
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class InPen extends JFrame implements Runnable{
double time = 0.0;
public static void main(String[] args){
InPen wnd=new InPen();
wnd.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});
wnd.setVisible(true);
}
public InPen(){
setTitle("Inverted Pendulum");
setBounds(300,100,800,700);
Thread thr = null;
if(thr == null){
thr = new Thread(this);
thr.start();
}
}
public void run(){
try{
Thread.sleep(1000);
}catch(Exception e){}
while(true){
move();
if(time > 5){
System.exit(0);
}
try{
repaint();
Thread.sleep(30);
}catch(Exception e){}
time = time + 0.001;
}
}
public void move(){
double step = 0.0001;
for(double ti = 0; ti < 0.01; ti = ti + step){
}
}
public void update(Graphics g){
paint(g);
}
public void paint(Graphics g){
super.paint(g);
int s = getSize().width/2;
g.drawLine(0,450,s*2,450);
}
}