新增TankFrame

Network
bingor_yhj 2 years ago
parent 7e1bedfa3f
commit ef93249b91

@ -1,9 +1,5 @@
package com.msb;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* @Author bingor
* @Date 2022-09-29 11:02
@ -13,17 +9,7 @@ import java.awt.event.WindowEvent;
public class TankDemo {
public static void main(String[] args) {
Frame frame = new Frame();
frame.setTitle("Tank war");
frame.setSize(200, 100);
frame.setResizable(true);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
TankFrame tankFrame = new TankFrame();
}
}

@ -0,0 +1,37 @@
package com.msb;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* @Author bingor
* @Date 2022-09-29 16:24
* @Description: com.msb
* @Version: 1.0
*/
public class TankFrame extends Frame {
private int x = 200;
private int y = 200;
public TankFrame() {
setTitle("Tank war");
setSize(800, 600);
setResizable(true);
setVisible(true);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
System.exit(0);
}
});
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.fillRect(x, y, 50, 50);
}
}
Loading…
Cancel
Save