日期:2014-05-20 浏览次数:20557 次
import java.awt.*; import java.awt.event.*; public class TankClient extends Frame{ private static int GAME_WIDTH = 800; private static int GAME_HEIGHT = 600; public static void main(String[] args) { new TankClient().launchFrame(); } Tank myTank = new Tank(50,50); public void launchFrame(){ Frame f = new Frame(); f.setBounds(222, 120, GAME_WIDTH, GAME_HEIGHT); f.setBackground(Color.GREEN); f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); f.setResizable(false); f.setVisible(true); } public void paint(Graphics g) { g.setColor(Color.GREEN); g.fillOval(30, 30, 50, 50); } }
import java.awt.*; import java.awt.event.*; public class TankClient extends Frame{ private static int GAME_WIDTH = 800; private static int GAME_HEIGHT = 600; public static void main(String[] args) { new TankClient(); } //Tank myTank = new Tank(50,50); public TankClient(){ //Frame f = new Frame(); setBounds(222, 120, GAME_WIDTH, GAME_HEIGHT); setBackground(Color.GREEN); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); setResizable(false); setVisible(true); } public void paint(Graphics g) { g.setColor(Color.RED); g.fillOval(30, 30, 50, 50); } }