📄 main.java
字号:
import java.awt.event.KeyEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Event;
import java.awt.BorderLayout;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.KeyStroke;
import java.awt.Point;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JFrame;
import javax.swing.JDialog;
import java.awt.Dimension;
import javax.swing.JList;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.BorderFactory;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTextArea;
import java.awt.Font;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ImageIcon;
import java.lang.String;
import javax.swing.table.DefaultTableModel;
public class Main {
private JFrame jFrame = null; // @jve:decl-index=0:visual-constraint="-12,-8"
private JPanel jContentPane = null;
private JMenuBar jJMenuBar = null;
private JMenu GameMenu = null;
private JMenu RecMenu = null;
private JMenu helpMenu = null;
private JMenuItem exitMenuItem = null;
private JMenuItem aboutMenuItem = null;
private JMenuItem RecMenuItem = null;
private JMenuItem StartMenuItem = null;
private JDialog aboutDialog = null; // @jve:decl-index=0:visual-constraint="555,577"
private JPanel aboutContentPane = null;
private JLabel aboutVersionLabel = null;
private JDialog StartDialog = null; // @jve:decl-index=0:visual-constraint="694,10"
private JPanel jContentPane1 = null;
private JList jList = null;
private JDialog RecDialog = null; // @jve:decl-index=0:visual-constraint="693,360"
private JPanel jContentPane2 = null;
private JLabel jLabel = null;
private JTextField jTextField = null;
private JPanel jPanel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JPanel jPanel1 = null;
private JButton jButton = null;
private JLabel jLabel3 = null;
private JLabel jLabel4 = null;
private JTextField jTextField1 = null;
private JComboBox jComboBox = null;
private JLabel jLabel5 = null;
private JLabel jLabel6 = null;
private JLabel jLabel7 = null;
private JComboBox jComboBox1 = null;
private JComboBox jComboBox2 = null;
private JComboBox jComboBox3 = null;
private JTextArea jTextArea = null;
private JPanel jPanel2 = null;
private JPanel jPanel3 = null;
private JPanel jPanel4 = null;
private JPanel jPanel5 = null;
private JLabel jLabel8 = null;
private JButton jButton1 = null;
private JButton jButton2 = null;
private JButton jButton3 = null;
private JScrollPane jScrollPane = null;
private JTable jTable = null;
private JLabel jLabel10 = null;
private JLabel jLabel11 = null;
private JLabel jLabel12 = null;
private JLabel jLabel13 = null;
private JLabel jLabel14 = null;
private JLabel jLabel15 = null;
private JLabel jLabel16 = null;
private JLabel jLabel17 = null;
private JLabel jLabel18 = null;
private JLabel jLabel19 = null;
private JLabel jLabel20 = null;
private JLabel jLabel21 = null;
private JLabel jLabel22 = null;
private JLabel jLabel23 = null;
private JButton jButton5 = null;
private JPanel jPanel6 = null;
private JPanel jPanel7 = null;
/**
* This method initializes StartDialog
*
* @return javax.swing.JDialog
*/
Computer computer =new Computer(); // @jve:decl-index=0:
int crr_opp,crr_my;
private JLabel jLabel24 = null;
private JDialog getStartDialog() {
if (StartDialog == null) {
StartDialog = new JDialog(getJFrame(),true);
StartDialog.setSize(new Dimension(263, 342));
StartDialog.setTitle("开局设置");
StartDialog.setContentPane(getJContentPane1());
}
return StartDialog;
}
/**
* This method initializes jContentPane1
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane1() {
if (jContentPane1 == null) {
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(10, 138, 55, 16));
jLabel2.setText("游戏设置");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(10, 5, 56, 20));
jLabel1.setText("基本信息");
jLabel = new JLabel();
jLabel.setText("玩家名称:");
jLabel.setBounds(new Rectangle(7, 16, 60, 18));
jContentPane1 = new JPanel();
jContentPane1.setLayout(null);
jContentPane1.setPreferredSize(new Dimension(250, 320));
jContentPane1.add(getJPanel(), null);
jContentPane1.add(jLabel1, null);
jContentPane1.add(jLabel2, null);
jContentPane1.add(getJPanel1(), null);
jContentPane1.add(getJButton(), null);
}
return jContentPane1;
}
/**
* This method initializes jList
*
* @return javax.swing.JList
*/
private JList getJList() {
if (jList == null) {
jList = new JList();
jList.setBounds(new Rectangle(5, 7, 162, 210));
}
return jList;
}
/**
* This method initializes RecDialog
*
* @return javax.swing.JDialog
*/
private JDialog getRecDialog() {
if (RecDialog == null) {
RecDialog = new JDialog(getJFrame());
RecDialog.setSize(new Dimension(464, 350));
RecDialog.setTitle("查看记录");
RecDialog.setContentPane(getJContentPane2());
}
return RecDialog;
}
/**
* This method initializes jContentPane2
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane2() {
if (jContentPane2 == null) {
jLabel23 = new JLabel();
jLabel23.setBounds(new Rectangle(198, 8, 66, 18));
jLabel23.setText("详细内容");
jLabel22 = new JLabel();
jLabel22.setBounds(new Rectangle(11, 8, 59, 21));
jLabel22.setText("记录列表");
jContentPane2 = new JPanel();
jContentPane2.setLayout(null);
jContentPane2.setPreferredSize(new Dimension(460, 320));
jContentPane2.add(jLabel22, null);
jContentPane2.add(jLabel23, null);
jContentPane2.add(getJButton5(), null);
jContentPane2.add(getJPanel6(), null);
jContentPane2.add(getJPanel7(), null);
}
return jContentPane2;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setText("玩家");
jTextField.setSize(new Dimension(60, 20));
jTextField.setLocation(new Point(70, 17));
}
return jTextField;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(7, 80, 60, 18));
jLabel4.setText("玩家性别:");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(7, 48, 60, 18));
jLabel3.setText("玩家年龄:");
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(10, 27, 228, 107));
jPanel.setBorder(BorderFactory.createLineBorder(Color.darkGray, 1));
jPanel.add(jLabel, null);
jPanel.add(getJTextField(), null);
jPanel.add(jLabel3, null);
jPanel.add(jLabel4, null);
jPanel.add(getJTextField1(), null);
jPanel.add(getJComboBox(), null);
}
return jPanel;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jLabel7 = new JLabel();
jLabel7.setBounds(new Rectangle(7, 80, 60, 18));
jLabel7.setText("倒 计 时:");
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(7, 48, 60, 18));
jLabel6.setText("电脑策略:");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(7, 16, 60, 18));
jLabel5.setText("对战回合:");
jPanel1 = new JPanel();
jPanel1.setLayout(null);
jPanel1.setBorder(BorderFactory.createLineBorder(Color.darkGray, 1));
jPanel1.setSize(new Dimension(228, 107));
jPanel1.setLocation(new Point(10, 158));
jPanel1.add(jLabel5, null);
jPanel1.add(jLabel6, null);
jPanel1.add(jLabel7, null);
jPanel1.add(getJComboBox1(), null);
jPanel1.add(getJComboBox2(), null);
jPanel1.add(getJComboBox3(), null);
}
return jPanel1;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(145, 275, 81, 23));
jButton.setText("确定");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
StartDialog.setVisible(false);// TODO Auto-generated Event stub actionPerformed()
}
});
}
return jButton;
}
/**
* This method initializes jTextField1
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField1() {
if (jTextField1 == null) {
jTextField1 = new JTextField();
jTextField1.setText("25");
jTextField1.setSize(new Dimension(60, 20));
jTextField1.setLocation(new Point(70, 48));
}
return jTextField1;
}
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
if (jComboBox == null) {
jComboBox = new JComboBox();
jComboBox.setSelectedIndex(-1);
jComboBox.setSize(new Dimension(60, 20));
jComboBox.setLocation(new Point(70, 80));
jComboBox.addItem("男");
jComboBox.addItem("女");
}
return jComboBox;
}
/**
* This method initializes jComboBox1
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox1() {
if (jComboBox1 == null) {
jComboBox1 = new JComboBox();
jComboBox1.setBounds(new Rectangle(75, 16, 80, 20));
jComboBox1.addItem("10回合");
jComboBox1.addItem("100回合");
jComboBox1.addItem("200回合");
}
return jComboBox1;
}
/**
* This method initializes jComboBox2
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox2() {
if (jComboBox2 == null) {
jComboBox2 = new JComboBox();
jComboBox2.setBounds(new Rectangle(74, 48, 80, 20));
}
return jComboBox2;
}
/**
* This method initializes jComboBox3
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox3() {
if (jComboBox3 == null) {
jComboBox3 = new JComboBox();
jComboBox3.setBounds(new Rectangle(74, 80, 80, 20));
jComboBox3.addItem("3秒");
jComboBox3.addItem("5秒");
}
return jComboBox3;
}
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setBounds(new Rectangle(5, 5, 245, 234));
}
return jTextArea;
}
/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel2() {
if (jPanel2 == null) {
jLabel24 = new JLabel();
jLabel24.setBounds(new Rectangle(60, 266, 169, 43));
jLabel24.setFont(new Font("Dialog", Font.BOLD, 24));
jLabel24.setHorizontalAlignment(SwingConstants.CENTER);
jLabel24.setText("");
jLabel19 = new JLabel();
jLabel19.setIcon(new ImageIcon(getClass().getResource("/Image/R_comp.jpg")));
jLabel19.setHorizontalAlignment(SwingConstants.CENTER);
jLabel19.setLocation(new Point(8, 93));
jLabel19.setSize(new Dimension(110, 110));
jLabel18 = new JLabel();
jLabel18.setIcon(new ImageIcon(getClass().getResource("/Image/P_human.JPG")));
jLabel18.setHorizontalAlignment(SwingConstants.CENTER);
jLabel18.setLocation(new Point(185, 93));
jLabel18.setSize(new Dimension(110, 110));
jLabel8 = new JLabel();
jLabel8.setBounds(new Rectangle(133, 131, 39, 36));
jLabel8.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
jLabel8.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel8.setHorizontalAlignment(SwingConstants.CENTER);
jLabel8.setFont(new Font("Arial", Font.BOLD, 24));
jLabel8.setText("VS");
jPanel2 = new JPanel();
jPanel2.setLayout(null);
jPanel2.setBounds(new Rectangle(4, 4, 433, 343));
jPanel2.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
jPanel2.add(jLabel8, null);
jPanel2.add(getJButton1(), null);
jPanel2.add(getJButton2(), null);
jPanel2.add(getJButton3(), null);
jPanel2.add(jLabel18, null);
jPanel2.add(jLabel19, null);
jPanel2.add(jLabel24, null);
}
return jPanel2;
}
/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPanel3 == null) {
jLabel15 = new JLabel();
jLabel15.setBounds(new Rectangle(10, 112, 219, 17));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -