亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這個程序沒有主函數,怎么能運行通過?

這個程序沒有主函數,怎么能運行通過?

二徒弟 2016-11-20 19:29:03
package?com.imooc; import?java.awt.*; import?java.awt.event.*; import?java.applet.*; public?class?BallThread?extends?Applet?implements?Runnable{ Thread?red,?blue; Graphics?redPen,?bluePen; int?t=0; public?void?init(){ red?=?new?Thread(this); blue?=?new?Thread(this); redPen?=?getGraphics(); bluePen?=?getGraphics(); redPen.setColor(Color.red); bluePen.setColor(Color.blue); } public?void?start(){ red.start(); blue.start(); } public?void?run(){ while(true){ t=t+1; if(Thread.currentThread()==red){ if(t>100)t=0; redPen.clearRect(0,0,110,400); redPen.fillOval(50,(int)(1.0/2*t*9.8),15,15); try{ red.sleep(40); }catch(InterruptedException?e){} }else?if(Thread.currentThread()==blue){ bluePen.clearRect(120,0,900,500); bluePen.fillOval(120+7*t,(int)(1.0/2*t*9.8),15,15); try{ blue.sleep(40); }catch(InterruptedException?e){} } } } }
查看完整描述

3 回答

?
慕運維1139315

TA貢獻84條經驗 獲得超21個贊

這不是線程嗎?Applet應該能運行吧

查看完整回答
反對 回復 2016-11-21
?
望遠

TA貢獻1017條經驗 獲得超1032個贊

java applet程序運行時不需要main方法


查看完整回答
反對 回復 2016-11-20
  • 3 回答
  • 1 關注
  • 1351 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號