-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b78
-
x86
-
linux
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux(all)
A DESCRIPTION OF THE PROBLEM :
getDefaultButton() returns null in Java 1.5.0 where it returned a JButton in java 1.4.2 and earlier. This occurs after placing a JoptionPane as the content pane of a JDialog.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JDialog and a JOptionPane.
Set the content pane of the JDialog to the JOptionPane.
Get the default button of the JDialog's root pane.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A JButton returned
ACTUAL -
null returned
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class OptionPaneBug extends JDialog {
public OptionPaneBug() {
setContentPane(new JOptionPane());
pack();
System.out.println(getRootPane().getDefaultButton());
//returns null
//used to return default button of JOptionPane
}
public static void main(String[] args) {
new OptionPaneBug();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use the setValue() method of the JOptionPane to achieve a similar effect to the button click.
Release Regression From : 1.4.2_05
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
###@###.### 2005-04-15 09:44:33 GMT
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux(all)
A DESCRIPTION OF THE PROBLEM :
getDefaultButton() returns null in Java 1.5.0 where it returned a JButton in java 1.4.2 and earlier. This occurs after placing a JoptionPane as the content pane of a JDialog.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JDialog and a JOptionPane.
Set the content pane of the JDialog to the JOptionPane.
Get the default button of the JDialog's root pane.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A JButton returned
ACTUAL -
null returned
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class OptionPaneBug extends JDialog {
public OptionPaneBug() {
setContentPane(new JOptionPane());
pack();
System.out.println(getRootPane().getDefaultButton());
//returns null
//used to return default button of JOptionPane
}
public static void main(String[] args) {
new OptionPaneBug();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use the setValue() method of the JOptionPane to achieve a similar effect to the button click.
Release Regression From : 1.4.2_05
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
###@###.### 2005-04-15 09:44:33 GMT
- relates to
-
JDK-4817630 AncestorEvent ancestorAdded thrown at JFrame creation, not at show()
- Resolved