Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6351748

JCheckBox setSelectedIcon not working

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      Windows: Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
      Linux: Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [5.00.2195]
      Linux 2.4.19-4GB #1 i686 unknown

      A DESCRIPTION OF THE PROBLEM :
      Setting the selected icon of a JCheckBox has no effect.

      Note:
      In fact setting the disabled icon or the disabled selected icon also has no effect.
      This is not only true for JCheckBox but also for JToggleButton (and probably others).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Set the selected icon of a JCheckBox.gt


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When the JCheckBox is selected the set icon is shown.
      ACTUAL -
      The JCheckBox shows the standard JCheckBox in selected state.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.FlowLayout;
      import javax.swing.*;

      /** Some example cb.gif needed! */
      public class cbtest extends JFrame {

          public cbtest() {

              JCheckBox cb1 = new JCheckBox("1");
              JCheckBox cb2 = new JCheckBox("2");

              cb2.setSelected(true);
              Icon icon = new ImageIcon("cb.gif");
              System.out.println(icon.getIconHeight());
              cb2.setSelectedIcon(icon);
              System.out.println(cb2.getSelectedIcon());

              this.getContentPane().setLayout(new FlowLayout());
              this.getContentPane().add(cb1);
              this.getContentPane().add(cb2);

          }

          public static void main (String args[]) {
              cbtest frame = new cbtest();
              frame.setLocation(100,200);
              frame.setSize(300,200);
              frame.setVisible(true);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Set all four icons together: default, selected, disabled, disabled selected.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: