【发布时间】:2014-02-15 02:44:52
【问题描述】:
如果是这样,有人可以解释如何让这幅画作画,以及为什么不画那会很棒!!!
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();
}
}
【问题讨论】:
-
它有自己的想法。
标签: java multithreading swing paint