- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
(编辑)此问题已解决 - 请参阅答案。
我遇到了一个我以前从未见过的 Java/Swing 和 Netbeans 的不幸问题。我在 Netbeans 中设计了一个基本的纸牌游戏形式,它看起来运行得很好。下图: /image/IcZ7F.png
请注意左下角的导航器 View ,它清楚地列出了底部面板中的所有组件。
当我实际运行游戏时,乍一看似乎还不错...... /image/SNKK8.png
...但是当您最大化窗口时,您突然会无缘无故地看到面板内容的副本。 /image/y0LhY.png
这种重叠不仅令人困惑,还会导致按钮事件指向错误的组件,从而使游戏完全无法玩。默认情况下,会显示正确的聊天文本区域,但是当您单击它来聚焦时,它会突然将空白文本区域也带到前面,从而有效地隐藏了聊天文本区域。
此问题也会影响顶部面板,其中有本应没有文本的 jLabels 虚拟重复项(如右侧所示)。
是什么原因导致此问题以及如何解决?我在导航器中找不到面板的重复项,清理和构建不起作用,甚至自动生成的代码也没有显示向窗口添加两个文本区域的提示。
非常感谢您的帮助!
(编辑)相关自动生成的 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>
最佳答案
我已找到并解决了该问题;在困惑的构造函数中,initComponents() 被调用了两次。我深感羞愧。
关于Java Swing 幽灵/双重组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24467597/
我正在开发一个摆动程序以显示多张图片。并且可以旋转图片(每个图片都以JComponent实现)。 问题是,当图片旋转时,JComponent的边框不会改变,因此图片会被剪切。 有什么办法也可以旋转边框
我有一个 JPanel 和一个 JButton 向量,我想将每个按钮添加到面板。 我遇到的问题是我有一个代表按钮向量的变量 btns,但宏函数只是将它视为一个符号,而不是一个向量。有没有办法以某种方式
我有一个 swing 应用程序,它覆盖 javax.swing.text.Document 以将基础文档的内容限制为某些字符和文本长度。我想将我的应用程序移植到 Javafx,但我不知道此类是否有 J
我有一个带有面板的简单应用程序,我想在单击它时暂停并重新开始绘画。 object ModulusPatterns extends SimpleSwingApplication { var dela
我似乎无法在 Swing 中强制布局。我有一个 JComponent添加到 JLayeredPane我在 JComponent 上设置了边框.然后,我想立即重新绘制所有内容 - 而不是像 invali
我有一个 Swing 应用程序,我想通过将外部文件从 Windows 资源管理器拖到应用程序上来导入外部文件。我有这个基本功能工作。但是,我想将默认的拖放光标图标更改为应用程序适当的光标。当鼠标键被按
我想在我的 Scala 摆动应用程序中使用一棵树,但该组件在 API 中不可用。 是否包装了 JTree存在吗? 如果没有,你对制作有什么建议吗? 谢谢 最佳答案 即使您可以在 Scala 程序中直接
我目前正在努力使我的 Swing 应用程序看起来更好。我想在这些方面实现一些目标: 这个想法是让每个框都有一个漂亮的标题,背景类似于上图。使用基本的 Swing 组件,我能得到的最接近的东西是添加 T
这是我在 Scala 中使用 Swing 的第一次实验,并且对下面的代码有一些疑问。它所做的只是生成一个带有可改变颜色的彩色矩形的窗口。请随时回答一个或任何一个问题。 1) 我在下面使用了 Java
一个愚蠢的问题,但我真的无法让它起作用:我在 Swing 应用程序中有一些长时间运行的过程,可能需要几分钟。我想在此过程进行时向用户显示进度对话框。我还想阻止用户执行进一步的操作,例如在进程进行时按下
如何获取秋千组件的默认背景色?我的意思是JPanel的默认背景色? 最佳答案 要获取创建面板时将使用的 DEFAULT 颜色,请使用: Color color = UIManager.getColor
我想更改特定表头的背景颜色。在我的应用程序中,我必须将当前月份的标题颜色设置为红色。 我的代码在这里:: jTable1.getTableHeader(). setDefaultRe
我正在努力使在 Java3D Canvas 上显示 Java Swing 组件并与之交互成为可能。我通过将透明 JPanel 绘制到缓冲图像来显示组件,然后使用 J3DGraphics2D 在 Can
嗨 当我在 swing 中创建按钮时,它会在文本周围添加边框,从而使按钮变大一点。 现在,我确实需要那个屏幕空间,我通常做的是创建一个文本项(禁用),它创建更小的组件大小(文本周围更小的空间)并向其添
有scala.swing.BoxPanel,但它似乎没有捕获重点,因为没有与javax.swing.Box工厂方法createHorizontalStrut等效的东西、createHorizo
我的 scala swing 应用程序中有一个 BoxPanel 按钮,这对我来说很难看,因为按钮的大小各不相同。我已将其更改为 GridPanel,但随后它们也垂直填充了面板,我发现这更难看。我怎样
我刚开始学习 Scala,作为学习过程的一部分,我一直在尝试使用 Swing 编写一些简单的脚本。 这是一个非常精简的例子,它展示了我所看到的问题。 SimpleSwingApp: import sc
我刚刚开始使用 clojure 和跷跷板制作 GUI 应用程序。它只创建一个 JFrame 和几个组件。这是代码。 main 函数除了调用 start-gui 什么也不做并在返回后立即退出。 (ns
Scala 是一种很棒的语言,但不幸的是缺少库文档。如何更改组件的初始大小?我什么都没有(故意),但无论如何都希望它是一定的。我目前有 ... contents = new BoxPanel(Orie
基本设置是这样的:我有一个垂直的 JSplitPane,我希望它有一个固定大小的底部组件和一个调整大小的顶部组件,我通过调用 setResizeWeight(1.0) 来完成。在此应用程序中,有一个按
我是一名优秀的程序员,十分优秀!