⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subframe.java

📁 用Java编写的一个五子棋小游戏代码! 有什么问题可以与我联系共同探讨!
💻 JAVA
字号:
/* * subFrame.java * * Created on November 19, 2006, 12:45 PM *//** * * @author  sammychen */public class subFrame extends javax.swing.JFrame {        /** Creates new form subFrame */    public subFrame() {                initComponents();        this.setResizable(false);        this.setTitle("Options For the Game");            }        /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        jPanel1 = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        jLabel2 = new javax.swing.JLabel();        player1Name = new javax.swing.JTextField();        jLabel3 = new javax.swing.JLabel();        player1Color = new javax.swing.JComboBox();        jLabel4 = new javax.swing.JLabel();        jLabel5 = new javax.swing.JLabel();        player2Name = new javax.swing.JTextField();        jLabel6 = new javax.swing.JLabel();        player2Color = new javax.swing.JComboBox();        jSeparator1 = new javax.swing.JSeparator();        optionSure = new javax.swing.JButton();        optionCancle = new javax.swing.JButton();        jLabel1.setText("Player 1");        jLabel2.setText("Player Name :");        player1Name.setText("writePlayer");        jLabel3.setText("Color :");        player1Color.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Red", "White" }));        jLabel4.setText("Player 2");        jLabel5.setText("Player Name:");        player2Name.setText("BlackPlayer");        jLabel6.setText("Color:");        player2Color.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Black", "Blue" }));        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);        jPanel1.setLayout(jPanel1Layout);        jPanel1Layout.setHorizontalGroup(            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)            .add(jPanel1Layout.createSequentialGroup()                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)                    .add(jLabel1)                    .add(jLabel4)                    .add(jPanel1Layout.createSequentialGroup()                        .addContainerGap()                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)                            .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup()                                .add(jLabel5)                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)                                .add(player2Name))                            .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup()                                .add(jLabel2)                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)                                .add(player1Name, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 81, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))                        .add(17, 17, 17)                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)                            .add(jLabel3)                            .add(jLabel6))                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)                            .add(player2Color, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                            .add(player1Color, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))                .addContainerGap(24, Short.MAX_VALUE))        );        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)            .add(jPanel1Layout.createSequentialGroup()                .add(jLabel1)                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel2)                    .add(player1Name, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                    .add(jLabel3)                    .add(player1Color, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .add(17, 17, 17)                .add(jLabel4)                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel5)                    .add(player2Name, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                    .add(jLabel6)                    .add(player2Color, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))        );        optionSure.setText("Sure");        optionSure.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                optionSureActionPerformed(evt);            }        });        optionCancle.setText("Cancle");        optionCancle.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                optionCancleActionPerformed(evt);            }        });        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)            .add(layout.createSequentialGroup()                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE)                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()                        .addContainerGap()                        .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))                .addContainerGap())            .add(layout.createSequentialGroup()                .add(31, 31, 31)                .add(optionSure)                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 142, Short.MAX_VALUE)                .add(optionCancle)                .add(60, 60, 60))        );        layout.setVerticalGroup(            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)            .add(layout.createSequentialGroup()                .addContainerGap()                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 53, Short.MAX_VALUE)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(optionSure)                    .add(optionCancle))                .addContainerGap())        );        pack();    }// </editor-fold>//GEN-END:initComponents    private void optionSureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optionSureActionPerformed        chessHead.whitePlayer.setName(this.player1Name.getText());        chessHead.whitePlayer.setColor((String)this.player1Color.getSelectedItem());        chessHead.blackPlayer.setName(this.player2Name.getText());        chessHead.blackPlayer.setColor((String)this.player2Color.getSelectedItem());        this.setVisible(false);// TODO add your handling code here:    }//GEN-LAST:event_optionSureActionPerformed    private void optionCancleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optionCancleActionPerformed// TODO add your handling code here:        this.setVisible(false);            }//GEN-LAST:event_optionCancleActionPerformed        /**     * @param args the command line arguments     */    public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new subFrame().setVisible(true);            }        });    }        // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JLabel jLabel4;    private javax.swing.JLabel jLabel5;    private javax.swing.JLabel jLabel6;    private javax.swing.JPanel jPanel1;    private javax.swing.JSeparator jSeparator1;    private javax.swing.JButton optionCancle;    private javax.swing.JButton optionSure;    private javax.swing.JComboBox player1Color;    private javax.swing.JTextField player1Name;    private javax.swing.JComboBox player2Color;    private javax.swing.JTextField player2Name;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -