第4个回答 2019-01-24
在eclipse中直接打开一个文件,而后点击RUN AS 按钮,而后在出现的RUN AS窗口中选择ANT BUILD,点击确定按钮后为什么不出现运行界面
在eclipse中直接打开一个文件,而后点击RUN AS 按钮,而后在出现的RUN AS窗口中选择ANT BUILD,点击确定按钮后为什么不出现运行界面。程序代码如下。刚刚开始学,啥也不会,请大家见谅。
文件名为:MyBall.java ,其内容如下:
import java.awt.*;
public class MyBall {
public static void main(String args[]){
Frame w = new Frame() ;
w.setSize(300 , 400) ;
MyPanel mp = new MyPanel() ;
w.add(mp) ;
Thread t = new Thread(mp) ;
t.start() ;
w.show() ;
}
}
class MyPanel extends Panel implements Runnable{
int x = 30 ;
int y = 30 ;
public void paint(Graphics g){
g.fillOval(x, y, 20, 20) ;
}
public void run() {
while(true){
y ++ ;
if(y>400){
y = 0 ;
}
try{
Thread.sleep(30) ;
}catch(Exception e){}
repaint() ;
}
}
}
ant在eclipse下出错