class MyPanel extends Panel implements Runnable{public void paint(Graphics g){g.setColor(Color.white);for(int i=0;i<150;i++){thread.sleep(100);//此处提示Unhandled exception type InterruptedException是什么意思g.drawString("*", (int)(Math.random()*600), (int)(Math.random()*450));}}public void run(){}MyPanel(){}}Thread是大写开头。我刚刚手打打错了
1 回答
catspeake
TA贡献1111条经验 获得超0个赞
class MyPanel extends Panel implements Runnable { public void paint(Graphics g) { g.setColor(Color.white); for (int i = 0; i < 150; i++) { try{ thread.sleep(100);//有异常需要捕获 }catch(Exception e){ e.printStackTrace(); } g.drawString("*", (int) (Math.random() * 600), (int) (Math.random() * 450)); } } public void run() { } MyPanel() { }} |
添加回答
举报
0/150
提交
取消
