黑马程序员技术交流社区
标题:
java多线程问题
[打印本页]
作者:
轻松过关
时间:
2012-12-19 10:15
标题:
java多线程问题
public class aa extends JFrame {
public aa() {
this.setBounds(100, 100, 400, 400);
this.setLayout(null);
this.setVisible(true);
bb l = new bb();
l.setBounds(20, 20, 15, 15);
this.add(l);
}
public static void main(String[] args) {
new aa();
}
}
class bb extends JLabel{
public bb() {
setSize(new Dimension( 10, 10));
setPreferredSize(new Dimension( 10, 10));
}
@Override
protected void paintComponent(final Graphics arg0) {
/*ScheduledExecutorService timer=Executors.newScheduledThreadPool(1);
timer.scheduleAtFixedRate(
new Runnable(){
@Override
public void run() {
//画不出图来
Graphics g=arg0;
//获得这个画图笔就能画出图来
//Graphics g=bb.this.getGraphics();
g.fillOval(0, 0, 15, 15);
System.out.println(new Date(System.currentTimeMillis()));
}
},
2,
3,
TimeUnit.SECONDS);*/
//这里也能画出图来
//arg0.fillOval(0, 0, 15, 15);
//这个也画不出图来?
this.getGraphics().fillOval(0, 0, 15, 15);
//new cc(arg0);
}
}上面所得的画笔为什么有的能画出图来?有的画不出来?求解!!!
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2