import java.awt.*;import java.awt.event.*;
public class Tankwar0 {


 class  TankClick1 extends Frame{

    
 int x;
 int y;
Image offImageScreen ;

public void update(Graphics g) {
if(offImageScreen != null){
offImageScreen = this.createImage(800,600);
Graphics goffScreenImage=getGraphics();
paint(goffScreenImage);
g.drawImage(offImageScreen, 0, 0, null);
}
} public void paint(Graphics g) {
Color c =g.getColor();
g.setColor(Color.red);
g.fillOval(x, y, 20, 20);
//g.setColor(Color.c);
//g.getColor();
  y =+5;
  }   public void launchFrame(){
this.setLocation(400,300);
this.setSize(600,800);
setVisible(true);
setTitle("TankWar");
      this.addWindowListener(new WindowAdapter(){
     
public void windowClosing(WindowEvent e) {
System.exit(0);

}
     
     
     
     
      });
      this.setBackground(this.getBackground().green);
     
      }
 }



class paintThread implements Runnable{
 public void run(){
 while(true){


 try {
Thread.sleep(50);
} catch (InterruptedException e) {

e.printStackTrace();
}
 }

 
 }
 
   

public void main(String[] args) {
Tankwar0 tc = new Tankwar0();
tc.launchFrame();
}
}
}


 

解决方案 »

  1.   

    改的部分红色显示拉!import java.awt.*;import java.awt.event.*;
    public class Tankwar0 {
    public static void main(String[] args) {
    TankClick1 tc = new TankClick1();
    tc.launchFrame();
    }
    }
     class TankClick1 extends Frame{
    int x=100; 
     int y=100;
     Image offImageScreen ;
     public void update(Graphics g) {
     if(offImageScreen != null){
     offImageScreen = this.createImage(800,600);
     Graphics goffScreenImage=getGraphics();
     paint(goffScreenImage);
     g.drawImage(offImageScreen, 0, 0, null);
     }
     }
     public void paint(Graphics g) {
     g.setColor(Color.BLACK);
     g.fillOval(x, y, 20, 20);
     y =+5;
     }     public void launchFrame(){
     this.setLocation(400,300);
     this.setSize(600,800);
     setVisible(true);
     setTitle("TankWar");
     this.addWindowListener(new WindowAdapter(){  public void windowClosing(WindowEvent e) {
     System.exit(0);  }
     });
     this.setBackground(this.getBackground().green);
     }
      }
      class paintThread implements Runnable{
      public void run(){
      while(true){
      try {
      Thread.sleep(50);
      } catch (InterruptedException e) {
      e.printStackTrace();
      }
      } 
      }
      }
      

  2.   

    是考试,还是找人解决,problem也不贴出来。
      

  3.   


    import java.awt.*;
    import java.awt.event.*;
    public class Tankwar0 {
    public static void main(String[] args) {
    TankClick1 tc = new TankClick1();
    tc.launchFrame();
    }
    }
    class paintThread implements Runnable{//把类放外面吧。
    public void run(){
    while(true){
    try {
    Thread.sleep(2);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }
    }
    class TankClick1 extends Frame{ //把类放外面吧。
    int x=30;
    int y=30;
    Image offImageScreen ;
    public void update(Graphics g) {
    if(offImageScreen != null){
    offImageScreen = this.createImage(800,600);
    Graphics goffScreenImage=getGraphics();
    paint(goffScreenImage);
    g.drawImage(offImageScreen, 0, 0, null);
    }
    }
    public void paint(Graphics g) {
    //Color c =g.getColor();
    g.setColor(Color.black);
    g.fillOval(x, y, 20, 20);
    //g.setColor(Color.c);
    //g.getColor();
    y =+5;
    }
    public void launchFrame(){
    this.setLocation(0,0);
    this.setSize(600,800);
    setVisible(true);
    setTitle("TankWar");
    this.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    }
    });
    this.setBackground(this.getBackground().green);
    }
    }