Java Swing ghost / doubled组件?

时间:2014-06-28 14:06:25

标签: java swing netbeans awt

(编辑)此问题已解决 - 请参阅答案。

我遇到了Java / Swing和Netbeans的一个不幸的问题,我以前从未见过。我在Netbeans中设计了一个基本的纸牌游戏形式,看起来效果很好。图片如下: http://i.imgur.com/Zvt2TYL.png

请注意左下角的导航器视图,清楚地列出了底部面板中的所有组件。

当我实际运行游戏时,乍一看似乎很好...... http://i.imgur.com/hhJfl8v.png

...但是当你最大化窗口时,你突然看到面板内容的副本没有明显的原因。 http://i.imgur.com/vPJgpUv.png

这种重叠不仅令人困惑,而且还会导致按钮事件指向错误的组件,从而使游戏完全无法播放。默认情况下会显示聊天的正确文本区域,但是当您单击它进行聚焦时,它会突然将空文本区域置于前面,从而有效地隐藏聊天文本区域。

此问题也会影响顶部面板,具有应该没有文本的jLabel虚拟副本(见右图)。

无论是什么导致这种情况以及如何解决?我无法在导航器中找到面板的副本,清理和构建不起作用,甚至自动生成的代码也没有显示任何向窗口添加两个文本区域的提示。

非常感谢帮助!

(编辑)相关的自动生成的initComponents代码如下。我从来没有碰过这个代码,因为它是由Netbeans自动生成的。

// Variables declaration - do not modify                     
private javax.swing.JLabel bC1;
private javax.swing.JLabel bC2;
private javax.swing.JLabel bC3;
private javax.swing.JLabel bC4;
private javax.swing.JLabel bC5;
private javax.swing.JLabel bC6;
private javax.swing.JLabel bC7;
private javax.swing.JSpinner betSpinner;
private javax.swing.JButton btnBet;
private javax.swing.JButton btnPass;
private javax.swing.JPanel gamePanel;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField jTextField1;
private javax.swing.JLabel lC1;
private javax.swing.JLabel lC2;
private javax.swing.JLabel lC3;
private javax.swing.JLabel lC4;
private javax.swing.JLabel lC5;
private javax.swing.JLabel lC6;
private javax.swing.JLabel lC7;
private javax.swing.JPanel playingField;
private javax.swing.JPanel plrBottom;
private javax.swing.JPanel plrLeft;
private javax.swing.JPanel plrRight;
private javax.swing.JPanel plrTop;
private javax.swing.JLabel rC1;
private javax.swing.JLabel rC2;
private javax.swing.JLabel rC3;
private javax.swing.JLabel rC4;
private javax.swing.JLabel rC5;
private javax.swing.JLabel rC6;
private javax.swing.JLabel rC7;
private javax.swing.JPanel statusPanel;
private javax.swing.JLabel tC1;
private javax.swing.JLabel tC2;
private javax.swing.JLabel tC3;
private javax.swing.JLabel tC4;
private javax.swing.JLabel tC5;
private javax.swing.JLabel tC6;
private javax.swing.JLabel tC7;
private javax.swing.JTextArea textAreaChat;
// End of variables declaration  

private void initComponents() {

    statusPanel = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    textAreaChat = new javax.swing.JTextArea();
    jTextField1 = new javax.swing.JTextField();
    jButton1 = new javax.swing.JButton();
    jLabel1 = new javax.swing.JLabel();
    betSpinner = new javax.swing.JSpinner();
    btnBet = new javax.swing.JButton();
    btnPass = new javax.swing.JButton();
    gamePanel = new javax.swing.JPanel();
    plrRight = new javax.swing.JPanel();
    rC1 = new javax.swing.JLabel();
    rC2 = new javax.swing.JLabel();
    rC3 = new javax.swing.JLabel();
    rC4 = new javax.swing.JLabel();
    rC5 = new javax.swing.JLabel();
    rC6 = new javax.swing.JLabel();
    rC7 = new javax.swing.JLabel();
    plrBottom = new javax.swing.JPanel();
    bC1 = new javax.swing.JLabel();
    bC2 = new javax.swing.JLabel();
    bC3 = new javax.swing.JLabel();
    bC4 = new javax.swing.JLabel();
    bC5 = new javax.swing.JLabel();
    bC6 = new javax.swing.JLabel();
    bC7 = new javax.swing.JLabel();
    plrLeft = new javax.swing.JPanel();
    lC1 = new javax.swing.JLabel();
    lC2 = new javax.swing.JLabel();
    lC3 = new javax.swing.JLabel();
    lC4 = new javax.swing.JLabel();
    lC5 = new javax.swing.JLabel();
    lC6 = new javax.swing.JLabel();
    lC7 = new javax.swing.JLabel();
    plrTop = new javax.swing.JPanel();
    tC1 = new javax.swing.JLabel();
    tC2 = new javax.swing.JLabel();
    tC3 = new javax.swing.JLabel();
    tC4 = new javax.swing.JLabel();
    tC5 = new javax.swing.JLabel();
    tC6 = new javax.swing.JLabel();
    tC7 = new javax.swing.JLabel();
    playingField = new javax.swing.JPanel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    statusPanel.setPreferredSize(new java.awt.Dimension(0, 180));

    textAreaChat.setEditable(false);
    textAreaChat.setColumns(20);
    textAreaChat.setRows(5);
    jScrollPane1.setViewportView(textAreaChat);

    jButton1.setText("Send");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jLabel1.setText("Betting");

    btnBet.setText("Bet");
    btnBet.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnBetActionPerformed(evt);
        }
    });

    btnPass.setText("Pass");
    btnPass.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPassActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
    statusPanel.setLayout(statusPanelLayout);
    statusPanelLayout.setHorizontalGroup(
        statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(statusPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(statusPanelLayout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addGap(0, 0, Short.MAX_VALUE))
                        .addGroup(statusPanelLayout.createSequentialGroup()
                            .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(btnBet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(betSpinner, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(btnPass, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addContainerGap())))))
    );
    statusPanelLayout.setVerticalGroup(
        statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(statusPanelLayout.createSequentialGroup()
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(betSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(btnBet)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(btnPass))
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(18, 18, 18)
            .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton1))
            .addGap(27, 27, 27))
    );

    getContentPane().add(statusPanel, java.awt.BorderLayout.PAGE_END);

    gamePanel.setLayout(new java.awt.BorderLayout());

    rC1.setText("jLabel1");
    rC1.setMaximumSize(new java.awt.Dimension(14, 34));
    rC1.setMinimumSize(new java.awt.Dimension(14, 34));
    rC1.setPreferredSize(new java.awt.Dimension(14, 34));

    rC2.setText("jLabel1");
    rC2.setMaximumSize(new java.awt.Dimension(14, 34));
    rC2.setMinimumSize(new java.awt.Dimension(14, 34));
    rC2.setPreferredSize(new java.awt.Dimension(14, 34));

    rC3.setText("jLabel1");
    rC3.setMaximumSize(new java.awt.Dimension(14, 34));
    rC3.setMinimumSize(new java.awt.Dimension(14, 34));
    rC3.setPreferredSize(new java.awt.Dimension(14, 34));

    rC4.setText("jLabel1");
    rC4.setMaximumSize(new java.awt.Dimension(14, 34));
    rC4.setMinimumSize(new java.awt.Dimension(14, 34));
    rC4.setPreferredSize(new java.awt.Dimension(14, 34));

    rC5.setText("jLabel1");
    rC5.setMaximumSize(new java.awt.Dimension(14, 34));
    rC5.setMinimumSize(new java.awt.Dimension(14, 34));
    rC5.setPreferredSize(new java.awt.Dimension(14, 34));

    rC6.setText("jLabel1");
    rC6.setMaximumSize(new java.awt.Dimension(14, 34));
    rC6.setMinimumSize(new java.awt.Dimension(14, 34));
    rC6.setPreferredSize(new java.awt.Dimension(14, 34));

    rC7.setText("jLabel1");
    rC7.setMaximumSize(new java.awt.Dimension(14, 34));
    rC7.setMinimumSize(new java.awt.Dimension(14, 34));
    rC7.setPreferredSize(new java.awt.Dimension(14, 34));

    javax.swing.GroupLayout plrRightLayout = new javax.swing.GroupLayout(plrRight);
    plrRight.setLayout(plrRightLayout);
    plrRightLayout.setHorizontalGroup(
        plrRightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(plrRightLayout.createSequentialGroup()
            .addGroup(plrRightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(rC1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(rC2, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(rC3, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(rC4, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(rC5, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(rC6, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(rC7, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap())
    );
    plrRightLayout.setVerticalGroup(
        plrRightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(plrRightLayout.createSequentialGroup()
            .addGap(5, 5, 5)
            .addComponent(rC1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(rC2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(rC3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(rC4, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(rC5, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(rC6, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(rC7, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    gamePanel.add(plrRight, java.awt.BorderLayout.LINE_END);

    bC1.setText("jLabel1");

    bC2.setText("jLabel1");

    bC3.setText("jLabel1");

    bC4.setText("jLabel1");

    bC5.setText("jLabel1");

    bC6.setText("jLabel1");

    bC7.setText("jLabel1");

    javax.swing.GroupLayout plrBottomLayout = new javax.swing.GroupLayout(plrBottom);
    plrBottom.setLayout(plrBottomLayout);
    plrBottomLayout.setHorizontalGroup(
        plrBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(plrBottomLayout.createSequentialGroup()
            .addGap(36, 36, 36)
            .addComponent(bC1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(bC2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(bC3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(bC4, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(bC5, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(bC6, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(bC7, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    plrBottomLayout.setVerticalGroup(
        plrBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(plrBottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
            .addComponent(bC1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(bC2, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(bC3, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(bC4, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(bC5, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(bC6, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(bC7, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
    );

    gamePanel.add(plrBottom, java.awt.BorderLayout.PAGE_END);

    lC1.setText("jLabel1");
    lC1.setMaximumSize(new java.awt.Dimension(14, 34));
    lC1.setMinimumSize(new java.awt.Dimension(14, 34));
    lC1.setPreferredSize(new java.awt.Dimension(14, 34));

    lC2.setText("jLabel1");
    lC2.setMaximumSize(new java.awt.Dimension(14, 34));
    lC2.setMinimumSize(new java.awt.Dimension(14, 34));
    lC2.setPreferredSize(new java.awt.Dimension(14, 34));

    lC3.setText("jLabel1");
    lC3.setMaximumSize(new java.awt.Dimension(14, 34));
    lC3.setMinimumSize(new java.awt.Dimension(14, 34));
    lC3.setPreferredSize(new java.awt.Dimension(14, 34));

    lC4.setText("jLabel1");
    lC4.setMaximumSize(new java.awt.Dimension(14, 34));
    lC4.setMinimumSize(new java.awt.Dimension(14, 34));
    lC4.setPreferredSize(new java.awt.Dimension(14, 34));

    lC5.setText("jLabel1");
    lC5.setMaximumSize(new java.awt.Dimension(14, 34));
    lC5.setMinimumSize(new java.awt.Dimension(14, 34));
    lC5.setPreferredSize(new java.awt.Dimension(14, 34));

    lC6.setText("jLabel1");
    lC6.setMaximumSize(new java.awt.Dimension(14, 34));
    lC6.setMinimumSize(new java.awt.Dimension(14, 34));
    lC6.setPreferredSize(new java.awt.Dimension(14, 34));

    lC7.setText("jLabel1");
    lC7.setMaximumSize(new java.awt.Dimension(14, 34));
    lC7.setMinimumSize(new java.awt.Dimension(14, 34));
    lC7.setPreferredSize(new java.awt.Dimension(14, 34));

    javax.swing.GroupLayout plrLeftLayout = new javax.swing.GroupLayout(plrLeft);
    plrLeft.setLayout(plrLeftLayout);
    plrLeftLayout.setHorizontalGroup(
        plrLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(plrLeftLayout.createSequentialGroup()
            .addGroup(plrLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(lC1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(lC2, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(lC3, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(lC4, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(lC5, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(lC6, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(lC7, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap())
    );
    plrLeftLayout.setVerticalGroup(
        plrLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(plrLeftLayout.createSequentialGroup()
            .addGap(5, 5, 5)
            .addComponent(lC1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(lC2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(lC3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(lC4, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(lC5, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(lC6, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(lC7, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    gamePanel.add(plrLeft, java.awt.BorderLayout.LINE_START);

    tC1.setText("jLabel1");

    tC2.setText("jLabel1");

    tC3.setText("jLabel1");

    tC4.setText("jLabel1");

    tC5.setText("jLabel1");

    tC6.setText("jLabel1");

    tC7.setText("jLabel1");

    javax.swing.GroupLayout plrTopLayout = new javax.swing.GroupLayout(plrTop);
    plrTop.setLayout(plrTopLayout);
    plrTopLayout.setHorizontalGroup(
        plrTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(plrTopLayout.createSequentialGroup()
            .addGap(37, 37, 37)
            .addComponent(tC1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(tC2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(tC3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(tC4, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(tC5, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(tC6, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(tC7, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    plrTopLayout.setVerticalGroup(
        plrTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(plrTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
            .addComponent(tC1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(tC2, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(tC3, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(tC4, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(tC5, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(tC6, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(tC7, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
    );

    gamePanel.add(plrTop, java.awt.BorderLayout.PAGE_START);

    javax.swing.GroupLayout playingFieldLayout = new javax.swing.GroupLayout(playingField);
    playingField.setLayout(playingFieldLayout);
    playingFieldLayout.setHorizontalGroup(
        playingFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 0, Short.MAX_VALUE)
    );
    playingFieldLayout.setVerticalGroup(
        playingFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 0, Short.MAX_VALUE)
    );

    gamePanel.add(playingField, java.awt.BorderLayout.CENTER);

    getContentPane().add(gamePanel, java.awt.BorderLayout.CENTER);

    pack();
}// </editor-fold>

1 个答案:

答案 0 :(得分:2)

我找到并解决了这个问题;在构造函数的混乱中,initComponents()被调用了两次。我深感惭愧。