文件名称:
fingerGusset1.2.rar
开发工具:
文件大小: 21kb
下载次数: 0
上传时间: 2011-04-18
详细说明: package com.skeyedu.fingerGuess; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JRadioButton; import javax.swing.JTextArea; import javax.swing.JTextField; public class MainFrame extends JFrame { private MainFrame fingerGuessing = this; private JButton stone; // 石头 private JButton scissors; // 剪刀 private JButton cloth; // 布 private JButton start; // 开始按钮 private JButton exit; // 退出按钮 private JLabel node; // 出拳提示 private JLabel resultShow; // 结果公布 private JTextArea text; // 游戏进程显示文本 private JPanel jpanel; private JRadioButton radioBut1; //单选按钮,选择模式娱乐 private JRadioButton radioBut2; //竞技模式 private ButtonGroup butGroup; //按钮组 private JTextField jushu; //局数输入文本框 private JButton setMode; //设置模式按钮 private Game game; private GameOper gameOper; public MainFrame() { this.init(); // 调用初始化方法 this.setSize(new Dimension(450, 460)); this.setContentPane(getJpanel()); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setResizable(false); this.setLocation(300, 150); this.setTitle("石头-剪刀-布"); this.setVisible(true); } public void init() { //初始化组件及其位置大小 game = new Game(); gameOper = new GameOper(); node = new JLabel("请单击下面按钮出拳!"); node.setBounds(new Rectangle(30, 60, 200, 30)); stone = new JButton(new ImageIcon("ico/shitou.jpg")); stone.setBounds(new Rectangle(30, 85, 55, 60)); stone.setEnabled(false); scissors = new JButton(new ImageIcon("ico/jiandao.jpg")); scissors.setBounds(new Rectangle(120, 85, 55, 60)); scissors.setEnabled(false); cloth = new JButton(new ImageIcon("ico/bu.jpg")); cloth.setBounds(new Rectangle(210, 85, 55, 60)); cloth.setEnabled(false); resultShow = new JLabel("游戏情况:总局数为"+game.getTotalTime()+",当前模式:"+((game.getGameMode()==0)?"娱乐模式":"竞技模式")); resultShow.setBounds(new Rectangle(30, 145, 500, 30)); text = new JTextArea(); text.setText("游戏进度显示:\n玩家 计算机 结果"); text.setEditable(false); text.setBounds(new Rectangle(30, 175, 400, 200)); start = new JButton("开始"); start.setBounds(new Rectangle(100, 385, 100, 30)); exit = new JButton("退出"); exit.setBounds(new Rectangle(205, 385, 100, 30)); radioBut1 = new JRadioButton("娱乐模式"); radioBut1.setSelected(true); radioBut2 = new JRadioButton("竞技模式"); butGroup=new ButtonGroup(); butGroup.add(radioBut1); butGroup.add(radioBut2); radioBut1.setBounds(new Rectangle(20,10,80,30)); radioBut2.setBounds(new Rectangle(100,10,80,30)); jushu = new JTextField(); jushu.setBounds(new Rectangle(20,40,60,20)); setMode = new JButton("设置局数"); setMode.setBounds(new Rectangle(80, 40, 100, 20)); } private JLabel getNode() { return node; } private JButton getStone() { stone.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { checkAndOutput("石头", 0); } }); return stone; } private JButton getScissors() { scissors.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { checkAndOutput("剪刀", 1); } }); return scissors; } private JButton getCloth() { cloth.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { checkAndOutput("布---", 2); } }); return cloth; } // 结果显示框提示 private JLabel getResultShow() { return resultShow; } // 进程及结果显示文本框 private JTextArea getText() { return text; } // 继续 private JButton getStart() { start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cloth.setEnabled(true); scissors.setEnabled(true); stone.setEnabled(true); text.setText("游戏进度显示:\n玩家 计算机 结果"); start.setText("重新開始"); game.resetGame(); } }); return start; } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.