Java中的JFrame和Frame问题?
public class TankJFrame extends Frame {
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
int x = 50, y = 50;
// 准备画坦克
public void paint(Graphics g) {
Color c = g.getColor();
g.setColor(Color.RED);
g.fillOval(x, y, 30, 30);
g.setColor(c);
y += 5;
}
public class PaintThread implements Runnable {
public void run() {
while (true) {
repaint();
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
使用Frame画圆是闪烁的画, 能正常画单独个一个圆, 如果把Frame换成JFrame画的圆就是连续的一条线