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

Icon of a selected ToggleButton in a ButtonGroup is not gray when disabled

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      Name: stC104175 Date: 08/17/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      If the selected JToggleButton in a ButtonGroup is disabled with setEnabled
      (false), the Icon of the JToggleButton is not shown gray. It is still colored.
      The text of the Button ist correctly disabled.
      If a not selected JToggleButton in a ButtonGroup is disabled, the Icon is shown
      gray.

      import javax.swing.*;
      import java.awt.*;

      public class ToggleButtonTest extends JFrame{

      public ToggleButtonTest(){
      super();

      getContentPane().setLayout(new FlowLayout());
      ImageIcon icon=new ImageIcon(getClass().getResource
      ("/javax/swing/plaf/metal/icons/Error.gif"));

      // create the ButtonGroup
      ButtonGroup buttonGroup=new ButtonGroup();
      // create a selected ToggleButton and add it to the group
      JToggleButton selectedToggleButton=new JToggleButton("selected
      Button", icon, true);
      getContentPane().add(selectedToggleButton);
      buttonGroup.add(selectedToggleButton);

      // create a not selected ToggleButton and add it to the group
      JToggleButton notSelectedToggleButton=new JToggleButton("not
      selected Button", icon, false);
      getContentPane().add(notSelectedToggleButton);
      buttonGroup.add(notSelectedToggleButton);

      // disable the selected ToggleButton
      selectedToggleButton.setEnabled(false);
      // decomment the following line to see the difference
      // notSelectedToggleButton.setEnabled(false);

      setSize(400,200);
      }

      public static void main(String[] argv){
      ToggleButtonTest bgf=new ToggleButtonTest();
      bgf.show();
      }
      }
      (Review ID: 104780)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              peterz Peter Zhelezniakov (Inactive)
              Reporter:
              stompkinsunw Sean Tompkins (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: