package ShootGame;
import java.awt.Button;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ShootGame extends JFrame
{
GamePanel jp;
JButton beginButton;
JButton settingsButton;
JButton helpButton;
public static BufferedImage startBackGound;
static
{
try {
startBackGound=ImageIO.read(ShootGame.class.getResource("startBackGround.jpg"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public ShootGame()
{
super("飞机大战");
setSize(1920,821);
jp=new GamePanel();
getContentPane().add(jp);
beginButton=new JButton("开始游戏");
settingsButton=new JButton("设置");
helpButton=new JButton("帮助");
jp.add(beginButton);
jp.add(settingsButton);
jp.add(helpButton);
beginButton.setBounds(500,500,100,20);
settingsButton.setBounds(500,530,100,20);
helpButton.setBounds(500,560,100,20);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
class GamePanel extends JPanel
{
GamePanel()
{
setLayout(null);
}
@Override
public void paint(Graphics g) {
// TODO Auto-generated method stub
super.paint(g);
g.drawImage(startBackGound, 0, 0, null);
}
}
public static void main(String[] args)
{
new ShootGame();
}
}