怎样使JLayeredPane分层窗格中重叠按钮点击不显示出来 10
我用的时NetBeans6.0.1,预览设计时没问题编译运行时出现问题底层按钮单击会显示。代码:publicclassJFrameextendsjavax.swing.J...
我用的时NetBeans 6.0.1,预览设计时没问题编译运行时出现问题底层按钮单击会显示。代码:
public class JFrame extends javax.swing.JFrame {
/** Creates new form JFrame */
public JFrame() {
initComponents();
}
private void initComponents() {
jLayeredPane1 = new javax.swing.JLayeredPane();
jToggleButton1 = new javax.swing.JToggleButton();
... //省略1-24
jToggleButton24 = new javax.swing.JToggleButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jToggleButton1.setIcon(new javax.swing.ImageIcon("C:\\1.jpg")); // NOI18N
jToggleButton1.setBounds(470, 240, 71, 96);
jLayeredPane1.add(jToggleButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);
...
jToggleButton24.setIcon(new javax.swing.ImageIcon("C:\\1.jpg")); // NOI18N
jToggleButton24.setBounds(10, 240, 71, 96);
jLayeredPane1.add(jToggleButton24, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 571, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(23, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(37, Short.MAX_VALUE))
);
pack();
}//
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrame().setVisible(true);
} });
}
private javax.swing.JLayeredPane jLayeredPane1;
private javax.swing.JToggleButton jToggleButton1;
...
private javax.swing.JToggleButton jToggleButton24;
想用JAVA做一个类似QQ斗地主的游戏,这时第一步的界面,我打算用按钮表示本家的纸牌,单击后纸牌向上移动但我的程序里单击会盖住其他的牌,寻解决方法! 展开
public class JFrame extends javax.swing.JFrame {
/** Creates new form JFrame */
public JFrame() {
initComponents();
}
private void initComponents() {
jLayeredPane1 = new javax.swing.JLayeredPane();
jToggleButton1 = new javax.swing.JToggleButton();
... //省略1-24
jToggleButton24 = new javax.swing.JToggleButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jToggleButton1.setIcon(new javax.swing.ImageIcon("C:\\1.jpg")); // NOI18N
jToggleButton1.setBounds(470, 240, 71, 96);
jLayeredPane1.add(jToggleButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);
...
jToggleButton24.setIcon(new javax.swing.ImageIcon("C:\\1.jpg")); // NOI18N
jToggleButton24.setBounds(10, 240, 71, 96);
jLayeredPane1.add(jToggleButton24, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 571, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(23, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(37, Short.MAX_VALUE))
);
pack();
}//
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrame().setVisible(true);
} });
}
private javax.swing.JLayeredPane jLayeredPane1;
private javax.swing.JToggleButton jToggleButton1;
...
private javax.swing.JToggleButton jToggleButton24;
想用JAVA做一个类似QQ斗地主的游戏,这时第一步的界面,我打算用按钮表示本家的纸牌,单击后纸牌向上移动但我的程序里单击会盖住其他的牌,寻解决方法! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询