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();
}
}
}
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();
}
}
}
解决方案 »
- 关于Struse和Spring作用的不同之处 请高手指点
- 请问IDEA的热键怎么更改啊
- 我需要考网络工程师不???网络又是搞什么的???
- 接口中的变量为何必须为static final
- jbuilder须要设置什么不???
- JTable的问题:如何自动滚动到选中的那一行
- IO问题
- 还是老问题:String创建对象的数量
- 如何从JDialog中调JFrame??? 急急急,马上给分
- Square is-a Rect? (more thoughts on immutable programming)
- java.lang.NoSuchMethodError: main
- ubuntu下的JAVA问题---SOS啊,在线等
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();
}
}
}
}
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);
}
}