-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0, 6
-
b46
-
generic, x86
-
generic, linux
-
Verified
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)
======================================================================
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)
======================================================================
- duplicates
-
JDK-6559153 RFE: ColorChooser.setEnabled(false) doesn't disable anything
- Closed