为什么没有出现坦克
import java.awt.*;import java.awt.event.*;
public class TankWar1 extends Frame{
public void print(Graphics g) {
Color c=g.getColor();
g.setColor(Color.RED);
g.fillOval(50, 50, 30, 30);
g.setColor(c);
}
public void lauchFrame(){
this.setLocation(400,300);
this.setTitle("TankWar");
this.setSize(600,600);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}}
);
this.setResizable(false);
this.setBackground(Color.GREEN);
setVisible(true);
}
public static void main(String[] args) {
TankWar1 tw=new TankWar1();
tw.lauchFrame();
}
}
--------------------编程问答-------------------- 重复发帖 快点结贴 要不就删帖了
--------------------编程问答-------------------- 第二贴了。。
public class TankWar1 extends Frame {
public void paint(Graphics g) {//方法名写错了
Color c = g.getColor();
g.setColor(Color.RED);
g.fillOval(50, 50, 30, 30);
g.setColor(c);
}
public void lauchFrame() {
this.setLocation(400, 300);
this.setTitle("TankWar");
this.setSize(600, 600);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
this.setResizable(false);
this.setBackground(Color.GREEN);
setVisible(true);
}
public static void main(String[] args) {
TankWar1 tw = new TankWar1();
tw.lauchFrame();
}
}
补充:Java , Eclipse