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

JColorChooser ignores setEnabled() function call

    XMLWordPrintable

Details

    • b46
    • generic, x86
    • generic, linux
    • Verified

    Description

      Name: vi73552 Date: 03/22/99


      Create a JColorChooser object and place it on a panel.
      Apply the setEnabled(boolean) function on this object.
      On setEnabled(false), the object should be grayed out,
      and no more color selection possible. setEnabled(true) should
      invert this.
      In fact, JColorChooser objects ignore the setEnabled(false) call.
      Selection of a color is always allowed.

      Sample Code:
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      /***********************************************************************
       * tests the JColorChooser class.
       * @author Annette Suendermann, SME GmbH
       ***********************************************************************/
      public class JColorChooserEnabled extends JFrame
      implements ActionListener
      {
        private JButton enableButton;
        private JButton disableButton;
        private JLabel lbl;
        private JColorChooser jcc;

        public JColorChooserEnabled ()
        {
          // Set the Title
          super( "JColorCHooser.setEnabled Test" );

          // Get the pane of the frame
          Container content = getContentPane();
      content.setLayout (new BorderLayout());

          // The Buttons to switch to color setting mode
          enableButton = new JButton ( "Enable JColorChooser" );
          enableButton.addActionListener ( this );
          disableButton = new JButton ( "Disable JColorChooser" );
          disableButton.addActionListener ( this );
          Box enabledBox = Box.createVerticalBox();
          enabledBox.add(Box.createGlue());
          enabledBox.add(enableButton);
          enabledBox.add(Box.createVerticalStrut(10));
          enabledBox.add(disableButton);
          enabledBox.add(Box.createGlue());
          content.add(enabledBox, BorderLayout.EAST);

          // The JColorChooser
          jcc = new JColorChooser ();
          jcc.setEnabled ( false );
          content.add(jcc, BorderLayout.CENTER);

          // Label
          lbl = new JLabel ( "Current Status: JColorChooser.isEnabled() = "
            + jcc.isEnabled() );
          content.add(lbl, BorderLayout.SOUTH);

          setSize ( new Dimension ( 600, 400 ) ) ;
          setVisible(true);
        }

        public static void main(String[] args)
        {
          JColorChooserEnabled jcc = new JColorChooserEnabled( );
          jcc.addWindowListener(new WindowAdapter()
            { public void windowClosing(WindowEvent e)
              {System.exit(0);}
            });
        }

        public void actionPerformed ( ActionEvent event )
        {
          if ( event.getSource() instanceof JButton )
          {
            JButton button = (JButton) event.getSource();
            if ( button.getText().equals ( enableButton.getText() ) )
            { jcc.setEnabled (true); }
            else if ( button.getText().equals ( disableButton.getText() ) )
            { jcc.setEnabled (false); }
            lbl.setText ( "New Status: JColorChooser.isEnabled() = "
                  + jcc.isEnabled() );
          }
        }
      }


      java full version "JDK-1.2-V"
      (Review ID: 55872)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              malenkov Sergey Malenkov (Inactive)
              vasya Vassili Igouchkine (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: