package bhq;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
/**
* <p>作者: 白贺强
* <p>日期: 2009-9-8
*/
public class Game
{
private JFrame jFrame = null;
private JPanel jContentPane = null;
private MessagePanel messagePanel = null;
private JMenuBar jJMenuBar = null;
private JMenu fileMenu = null;
private JMenu helpMenu = null;
private JMenuItem exitMenuItem = null;
private JMenuItem aboutMenuItem = null;
private JMenuItem initMenuItem = null;
private JMenuItem startMenuItem = null;
private JMenuItem airPlaneMenuItem = null;
private JDialog aboutDialog = null;
private JPanel aboutContentPane = null;
private JLabel aboutVersionLabel = null;
private PlaneManager planemanager = null;
private PlaneManager manager = null;
private AirPlane plane = null;
private MultiJabberServer server = null;
private JTextField jTextFieldIP = null;
/**
* <p>[方法功能中文描述]</p>
* @param args
*/
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
Game application = new Game();
application.getJFrame().setVisible(true);
}
});
}
private void init()
{
String ip = this.getJTextFieldIP().getText().trim();
planemanager = new PlaneManager(0,ip);
planemanager.setLocation(10, 150);
getJContentPane().add(planemanager, null);
plane = new AirPlane(planemanager);
plane.setLocation(10, 10);
getJContentPane().add(plane, null);
getJContentPane().setComponentZOrder(plane, 0);
manager = new PlaneManager(1,ip);
manager.setLocation(220, 150);
getJContentPane().add(manager, null);
getJContentPane().repaint();
messagePanel = new MessagePanel(planemanager,manager);
getJContentPane().add(messagePanel, null);
server = new MultiJabberServer(messagePanel);
server.start();
jContentPane.add(getJTextFieldIP(), null);
getJContentPane().repaint();
}
/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
private JFrame getJFrame()
{
if (jFrame == null)
{
jFrame = new JFrame();
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setJMenuBar(getJJMenuBar());
jFrame.setSize(500, 500);
jFrame.setContentPane(getJContentPane());
jFrame.setTitle("Application");
//初始化
init();
}
return jFrame;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane()
{
if (jContentPane == null)
{
jContentPane = new JPanel()
{
private static final long serialVersionUID = 1L;
public void paint(Graphics g)
{
super.paint(g);
//绘制数字
int s = 'A';
for(int i=0;i<10;i++)
{
String str = String.valueOf((char)(s+i));
g.drawString(str, 15+i*20, 150);
g.drawString(String.valueOf(i), 0, 165+i*20);
g.drawString(str, 210+15+i*20, 150);
g.drawString(String.valueOf(i), 210, 165+i*20);
}
}
};
jContentPane.setLayout(null);
}
return jContentPane;
}
/**
* This method initializes jJMenuBar
*
* @return javax.swing.JMenuBar
*/
private JMenuBar getJJMenuBar()
{
if (jJMenuBar == null)
{
jJMenuBar = new JMenuBar();
jJMenuBar.add(getFileMenu());
jJMenuBar.add(getHelpMenu());
}
return jJMenuBar;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getFileMenu()
{
if (fileMenu == null)
{
fileMenu = new JMenu();
fileMenu.setText("File");
fileMenu.add(getInitMenuItem());
fileMenu.add(getAirPlaneMenuItem());
fileMenu.add(getStartMenuItem());
fileMenu.add(getExitMenuItem());
}
return fileMenu;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getHelpMenu()
{
if (helpMenu == null)
{
helpMenu = new JMenu();
helpMenu.setText("Help");
helpMenu.add(getAboutMenuItem());
}
return helpMenu;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getExitMenuItem()
{
if (exitMenuItem == null)
{
exitMenuItem = new JMenuItem();
exitMenuItem.setText("Exit");
exitMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
}
return exitMenuItem;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getAboutMenuItem()
{
if (aboutMenuItem == null)
{
aboutMenuItem = new JMenuItem();
aboutMenuItem.setText("About");
aboutMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JDialog aboutDialog = getAboutDialog();
aboutDialog.pack();
Point loc = getJFrame().getLocation();
loc.translate(20, 20);
aboutDialog.setLocation(loc);
aboutDialog.setVisible(true);
}
});
}
return aboutMenuItem;
}
/**
* This method initializes aboutDialog
*
* @return javax.swing.JDialog
*/
private JDialog getAboutDialog()
{
if (aboutDialog == null)
{
aboutDialog = new JDialog(getJFrame(), true);
aboutDialog.setTitle("About");
aboutDialog.setContentPane(getAboutContentPane());
}
return aboutDialog;
}
/**
* This method initializes aboutContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getAboutContentPane()
{
if (aboutContentPane == null)
{
aboutContentPane = new JPanel();
aboutContentPane.setLayout(new BorderLayout());
aboutContentPane.setPreferredSize(new Dimension(200, 100)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
怀旧一下,相信好多人都玩过,在纸上画几个方格,再添加几个不同方向的飞机,之后就开始大喊大叫:“打中你翅膀啦,打中你脑袋啦!”。现在写了一个两个人局域网打飞机的游戏。输入对方IP地址,最多摆放5架飞机,击中所有飞机头获胜。java applet小程序,可以学习到socket应用。适合不能上外网,又不爱玩windows自带那几个游戏的人,来试试这个小游戏吧~-Nostalgic look, I believe many people have played, a few paintings on paper box, and then add a few different directions of aircraft, began screaming after: " You hit the wing friends, hit your head it!" . Now two people to write a play LAN games aircraft. Enter each other' s IP address, put up five aircraft, all aircraft hit the first victory. java applet applet, you can learn to socket applications. For not on the external network, not fond of playing a few games that comes with windows people to try this game it ~
资源推荐
资源详情
资源评论
收起资源包目录
AirPlane.rar (35个子文件)
ui.gif 56KB
AirPlane
.project 504B
bhq
Applet$3.class 1KB
AirPlane$1.class 1KB
Game.class 7KB
Game.java 12KB
Game$7.class 1KB
Applet$2.class 1KB
ServeOneJabber.class 3KB
MultiJabberClient.java 5KB
AirPlane.class 6KB
JabberClientThread.class 3KB
PlaneManager.class 7KB
MultiJabberServer.class 1KB
Game$2.class 1014B
PlaneManager.java 10KB
MultiJabberClient.class 339B
Game$4.class 1KB
Game$1.class 628B
Applet$1.class 1KB
MessagePanel.class 2KB
Game$3.class 683B
MultiJabberServer.java 4KB
MessagePanel.java 3KB
AirPlane.java 8KB
Game$6.class 1KB
Applet$4.class 1KB
Applet.java 6KB
PlaneManager$1.class 2KB
Applet.class 4KB
AirPlane$2.class 2KB
Game$5.class 1KB
java.policy.applet 141B
.classpath 226B
Game.jar 33KB
共 35 条
- 1
资源评论
- hfanatcsdn2017-04-18看看,学习一下
baiheqiang
- 粉丝: 3
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功