-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
tiger
-
x86
-
windows_2000
Name: jk109818 Date: 02/20/2003
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
JColorChooser's createDialog method takes an ok listener
and a cancel listener. However, neither are called when
the "X" in the frame is clicked and the dialog is hidden.
I would presume that the "X" should be equivalent to cancel.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Create a JColorChooser with an okListener and
cancelListener
2.Close the dialog by clicking "X"
3.Neither the okListener, nor the cancelListener are called.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect the cancelListener to be called when you
click the "X".
----- BEGIN SOURCE -----
import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
/**
* This color test proved that nothing gets called when the user clicks on
* the "x" in the color chooser's frame. If the user clicks "ok", then the console prints,
* "You chose a new color" while if the user clicks cancel, the console
* prints, "Changed your mind, eh?"
*
* Neither gets printed when the user clicks the "x" which means that there's
* a problem.
*/
public class ColorTest
{
public static void main( String[] args )
{
new ColorTest( ) ;
}
public ColorTest( )
{
final JButton button = new JButton( "Pick a new color!" ) ;
final JColorChooser chooser = new JColorChooser( ) ;
final JFrame frame = new JFrame( "Color Test" ) ;
final ActionListener okListener, cancelListener ;
okListener = new ActionListener( ) {
public void actionPerformed( ActionEvent evt ) {
button.setBackground( chooser.getColor( ) ) ;
System.out.println( "You chose a new color: " + chooser.getColor( ) ) ;
}
} ;
cancelListener = new ActionListener( ) {
public void actionPerformed( ActionEvent evt ) {
System.out.println( "Changed your mind, eh?" ) ;
}
} ;
button.addActionListener( new ActionListener( ) {
public void actionPerformed( ActionEvent evt ) {
// Adding listeners here
final JDialog dialog = JColorChooser.createDialog( button,
"Pick a color!",
true,
chooser,
okListener,
cancelListener ) ;
dialog.setVisible( true ) ;
}
} ) ;
frame.getContentPane( ).add( button ) ;
frame.pack( ) ;
frame.setVisible( true ) ;
}
}
---- END SOURCE ----
REPRODUCIBILITY :
This bug can be reproduced always.
(Review ID: 180367)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
JColorChooser's createDialog method takes an ok listener
and a cancel listener. However, neither are called when
the "X" in the frame is clicked and the dialog is hidden.
I would presume that the "X" should be equivalent to cancel.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Create a JColorChooser with an okListener and
cancelListener
2.Close the dialog by clicking "X"
3.Neither the okListener, nor the cancelListener are called.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect the cancelListener to be called when you
click the "X".
----- BEGIN SOURCE -----
import javax.swing.* ;
import java.awt.event.* ;
import java.awt.* ;
/**
* This color test proved that nothing gets called when the user clicks on
* the "x" in the color chooser's frame. If the user clicks "ok", then the console prints,
* "You chose a new color" while if the user clicks cancel, the console
* prints, "Changed your mind, eh?"
*
* Neither gets printed when the user clicks the "x" which means that there's
* a problem.
*/
public class ColorTest
{
public static void main( String[] args )
{
new ColorTest( ) ;
}
public ColorTest( )
{
final JButton button = new JButton( "Pick a new color!" ) ;
final JColorChooser chooser = new JColorChooser( ) ;
final JFrame frame = new JFrame( "Color Test" ) ;
final ActionListener okListener, cancelListener ;
okListener = new ActionListener( ) {
public void actionPerformed( ActionEvent evt ) {
button.setBackground( chooser.getColor( ) ) ;
System.out.println( "You chose a new color: " + chooser.getColor( ) ) ;
}
} ;
cancelListener = new ActionListener( ) {
public void actionPerformed( ActionEvent evt ) {
System.out.println( "Changed your mind, eh?" ) ;
}
} ;
button.addActionListener( new ActionListener( ) {
public void actionPerformed( ActionEvent evt ) {
// Adding listeners here
final JDialog dialog = JColorChooser.createDialog( button,
"Pick a color!",
true,
chooser,
okListener,
cancelListener ) ;
dialog.setVisible( true ) ;
}
} ) ;
frame.getContentPane( ).add( button ) ;
frame.pack( ) ;
frame.setVisible( true ) ;
}
}
---- END SOURCE ----
REPRODUCIBILITY :
This bug can be reproduced always.
(Review ID: 180367)
======================================================================
- relates to
-
JDK-6514174 JColorChooser.createDialog should NOT dispose dialog
- Closed