如果有人可以解釋如何得到這個畫和爲什麼它不是畫很棒!線程不想工作
public class Main extends JPanel implements Runnable {
public void run() {
System.out.println("g");
repaint();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawRect(50, 50, 200, 200);
}
public static void main(String[] args) {
JFrame frame = new JFrame("Physics!");
frame.setSize(500, 500);
frame.setBackground(Color.BLUE);
frame.setVisible(true);
Main physics = new Main();
Thread t = new Thread(physics);
t.start();
}
}
它有自己的想法。 –