-
Bug
-
Resolution: Won't Fix
-
P5
-
None
-
5.0
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_06-b05, mixed mode
ADDITIONAL OS VERSION INFORMATION :
SUSE10 Pro, AMD64
EXTRA RELEVANT SYSTEM CONFIGURATION :
64 bit jdk 1.5.0_06
A DESCRIPTION OF THE PROBLEM :
Unselecting a JCheckBox button should turn off the check mark.
ButtonGroup has a number of JCheckBox buttons. setSelected(button, false) should turn off the check if the JCheckBox button is selected?
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the two classes and run PanelTest. Select a checkbox and then
push the "Push Me" button. Select the same checkbox again and the checkbox is not unselected.
Relevant lines of code (which I think
should work but do not) are lines 74 - 78 of class PanelTest.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
check mark should be turned off when setSelected(button, false) is executed.
ACTUAL -
the check remains turned on indicating the button is still selected.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* PanelTest.java
*
* Created on February 14, 2006, 7:47 AM
*/
package bttongrouptest;
import javax.swing.*;
/**
*
* @author chuck
*/
public class PanelTest extends javax.swing.JFrame {
/** Creates new form PanelTest */
public PanelTest() {
initComponents();
}
/** 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() {
paneLeft = new javax.swing.JSplitPane();
paneRignt = new javax.swing.JSplitPane();
btnPush = new javax.swing.JButton();
btnMessage = new javax.swing.JButton();
buttonGroupPanel1 = new bttongrouptest.ButtonGroupPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnPush.setText("Push Me");
btnPush.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPushActionPerformed(evt);
}
});
paneRignt.setLeftComponent(btnPush);
paneRignt.setRightComponent(btnMessage);
paneLeft.setRightComponent(paneRignt);
paneLeft.setLeftComponent(buttonGroupPanel1);
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()
.addContainerGap()
.add(paneLeft,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.add(paneLeft,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnPushActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_btnPushActionPerformed
// when you run this class, select one of the checkboxes before pressing
// the "Push Me" button
ButtonGroup btnGroup = buttonGroupPanel1.getButtonGroup();
if(btnGroup == null) System.out.println("the button group is null");
ButtonModel model = btnGroup.getSelection();
if(model == null) System.out.println("the button model is null");
btnGroup.setSelected(model, false);
btnMessage.setText("Now the selected checkbox should be unselected?");
}//GEN-LAST:event_btnPushActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PanelTest().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnMessage;
private javax.swing.JButton btnPush;
private bttongrouptest.ButtonGroupPanel buttonGroupPanel1;
private javax.swing.JSplitPane paneLeft;
private javax.swing.JSplitPane paneRignt;
// End of variables declaration//GEN-END:variables
}
/*
* ButtonGroupPanel.java
*
* Created on February 14, 2006, 7:39 AM
*/
package bttongrouptest;
import javax.swing.*;
/**
*
* @author chuck
*/
public class ButtonGroupPanel extends javax.swing.JPanel {
/** Creates new form ButtonGroupPanel */
public ButtonGroupPanel() {
initComponents();
}
public ButtonGroup getButtonGroup() {
return btnGroup;
}
/** 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() {
btnGroup = new javax.swing.ButtonGroup();
jCheckBox1 = new javax.swing.JCheckBox();
jCheckBox2 = new javax.swing.JCheckBox();
jCheckBox3 = new javax.swing.JCheckBox();
jCheckBox4 = new javax.swing.JCheckBox();
jCheckBox5 = new javax.swing.JCheckBox();
jCheckBox6 = new javax.swing.JCheckBox();
jCheckBox7 = new javax.swing.JCheckBox();
jCheckBox8 = new javax.swing.JCheckBox();
btnGroup.add(jCheckBox1);
jCheckBox1.setText("jCheckBox1");
jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox2);
jCheckBox2.setText("jCheckBox2");
jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox2.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox3);
jCheckBox3.setText("jCheckBox3");
jCheckBox3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox3.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox4);
jCheckBox4.setText("jCheckBox4");
jCheckBox4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox4.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox5);
jCheckBox5.setText("jCheckBox5");
jCheckBox5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox5.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox6);
jCheckBox6.setText("jCheckBox6");
jCheckBox6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox6.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox7);
jCheckBox7.setText("jCheckBox7");
jCheckBox7.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox7.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox8);
jCheckBox8.setText("jCheckBox8");
jCheckBox8.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox8.setMargin(new java.awt.Insets(0, 0, 0, 0));
org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jCheckBox1)
.add(jCheckBox2)
.add(jCheckBox3)
.add(jCheckBox4)
.add(jCheckBox5)
.add(jCheckBox6)
.add(jCheckBox7)
.add(jCheckBox8))
.addContainerGap(126, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jCheckBox1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox4)
.add(16, 16, 16)
.add(jCheckBox5)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox6)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox7)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox8)
.addContainerGap(159, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup btnGroup;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JCheckBox jCheckBox3;
private javax.swing.JCheckBox jCheckBox4;
private javax.swing.JCheckBox jCheckBox5;
private javax.swing.JCheckBox jCheckBox6;
private javax.swing.JCheckBox jCheckBox7;
private javax.swing.JCheckBox jCheckBox8;
// End of variables declaration//GEN-END:variables
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
ignore the problem but when focus has shifted to another JPanel I'd like to be able to uncheck the button
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_06-b05, mixed mode
ADDITIONAL OS VERSION INFORMATION :
SUSE10 Pro, AMD64
EXTRA RELEVANT SYSTEM CONFIGURATION :
64 bit jdk 1.5.0_06
A DESCRIPTION OF THE PROBLEM :
Unselecting a JCheckBox button should turn off the check mark.
ButtonGroup has a number of JCheckBox buttons. setSelected(button, false) should turn off the check if the JCheckBox button is selected?
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the two classes and run PanelTest. Select a checkbox and then
push the "Push Me" button. Select the same checkbox again and the checkbox is not unselected.
Relevant lines of code (which I think
should work but do not) are lines 74 - 78 of class PanelTest.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
check mark should be turned off when setSelected(button, false) is executed.
ACTUAL -
the check remains turned on indicating the button is still selected.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* PanelTest.java
*
* Created on February 14, 2006, 7:47 AM
*/
package bttongrouptest;
import javax.swing.*;
/**
*
* @author chuck
*/
public class PanelTest extends javax.swing.JFrame {
/** Creates new form PanelTest */
public PanelTest() {
initComponents();
}
/** 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() {
paneLeft = new javax.swing.JSplitPane();
paneRignt = new javax.swing.JSplitPane();
btnPush = new javax.swing.JButton();
btnMessage = new javax.swing.JButton();
buttonGroupPanel1 = new bttongrouptest.ButtonGroupPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnPush.setText("Push Me");
btnPush.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPushActionPerformed(evt);
}
});
paneRignt.setLeftComponent(btnPush);
paneRignt.setRightComponent(btnMessage);
paneLeft.setRightComponent(paneRignt);
paneLeft.setLeftComponent(buttonGroupPanel1);
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()
.addContainerGap()
.add(paneLeft,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.add(paneLeft,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnPushActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_btnPushActionPerformed
// when you run this class, select one of the checkboxes before pressing
// the "Push Me" button
ButtonGroup btnGroup = buttonGroupPanel1.getButtonGroup();
if(btnGroup == null) System.out.println("the button group is null");
ButtonModel model = btnGroup.getSelection();
if(model == null) System.out.println("the button model is null");
btnGroup.setSelected(model, false);
btnMessage.setText("Now the selected checkbox should be unselected?");
}//GEN-LAST:event_btnPushActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PanelTest().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnMessage;
private javax.swing.JButton btnPush;
private bttongrouptest.ButtonGroupPanel buttonGroupPanel1;
private javax.swing.JSplitPane paneLeft;
private javax.swing.JSplitPane paneRignt;
// End of variables declaration//GEN-END:variables
}
/*
* ButtonGroupPanel.java
*
* Created on February 14, 2006, 7:39 AM
*/
package bttongrouptest;
import javax.swing.*;
/**
*
* @author chuck
*/
public class ButtonGroupPanel extends javax.swing.JPanel {
/** Creates new form ButtonGroupPanel */
public ButtonGroupPanel() {
initComponents();
}
public ButtonGroup getButtonGroup() {
return btnGroup;
}
/** 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() {
btnGroup = new javax.swing.ButtonGroup();
jCheckBox1 = new javax.swing.JCheckBox();
jCheckBox2 = new javax.swing.JCheckBox();
jCheckBox3 = new javax.swing.JCheckBox();
jCheckBox4 = new javax.swing.JCheckBox();
jCheckBox5 = new javax.swing.JCheckBox();
jCheckBox6 = new javax.swing.JCheckBox();
jCheckBox7 = new javax.swing.JCheckBox();
jCheckBox8 = new javax.swing.JCheckBox();
btnGroup.add(jCheckBox1);
jCheckBox1.setText("jCheckBox1");
jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox2);
jCheckBox2.setText("jCheckBox2");
jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox2.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox3);
jCheckBox3.setText("jCheckBox3");
jCheckBox3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox3.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox4);
jCheckBox4.setText("jCheckBox4");
jCheckBox4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox4.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox5);
jCheckBox5.setText("jCheckBox5");
jCheckBox5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox5.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox6);
jCheckBox6.setText("jCheckBox6");
jCheckBox6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox6.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox7);
jCheckBox7.setText("jCheckBox7");
jCheckBox7.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox7.setMargin(new java.awt.Insets(0, 0, 0, 0));
btnGroup.add(jCheckBox8);
jCheckBox8.setText("jCheckBox8");
jCheckBox8.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
0, 0, 0));
jCheckBox8.setMargin(new java.awt.Insets(0, 0, 0, 0));
org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jCheckBox1)
.add(jCheckBox2)
.add(jCheckBox3)
.add(jCheckBox4)
.add(jCheckBox5)
.add(jCheckBox6)
.add(jCheckBox7)
.add(jCheckBox8))
.addContainerGap(126, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jCheckBox1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox4)
.add(16, 16, 16)
.add(jCheckBox5)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox6)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox7)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBox8)
.addContainerGap(159, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup btnGroup;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JCheckBox jCheckBox3;
private javax.swing.JCheckBox jCheckBox4;
private javax.swing.JCheckBox jCheckBox5;
private javax.swing.JCheckBox jCheckBox6;
private javax.swing.JCheckBox jCheckBox7;
private javax.swing.JCheckBox jCheckBox8;
// End of variables declaration//GEN-END:variables
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
ignore the problem but when focus has shifted to another JPanel I'd like to be able to uncheck the button