-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b03
-
x86
-
windows_xp
-
Verified
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
ver winxp home svc. pack 2
A DESCRIPTION OF THE PROBLEM :
When an item in joptionpane is doubleclicked, then [cancel] is clicked the value returned is NOT null, as it should be. Instead it is as if the user had selected the [ok] button because the returned value is not null.
Works fine when item is clicked only once!
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. double click item from joptionpane (list)
2. click cancel button or [x] from title bar.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Joptiondialog should return a null value when cancel button is clicked
ACTUAL -
joptionpane returns the item that was double clicked EVEN THOUGH cancel button was pressed after double clicking item
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.reflect.Array;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
class Test extends JFrame {
public void showTestOptionDialog() {
Object[] selectedItems = new Object[40];
for (int i = 0; i < 39; i++) {
selectedItems[i] = ("item :" + i);
}
String answer = (String) JOptionPane.showInputDialog(this,
"Double click on selected item then click cancel",
"Test Option Dialog", JOptionPane.WARNING_MESSAGE, null,
selectedItems, selectedItems[0]);
// if cancel clicked
if (answer == null) {
JOptionPane.showMessageDialog(null,
"Cancel clicked (answer should be null!), answer = " + answer,
null,
JOptionPane.INFORMATION_MESSAGE);
System.out.println("Cancel clicked, answer = " + answer);
// selectedItems = null;
return;
// else if OK clicked
} else if (answer != null) {
JOptionPane.showMessageDialog(null,
"OK clicked, answer = " + answer,
null,
JOptionPane.INFORMATION_MESSAGE);
System.out.println("OK clicked, answer =" + answer);
}
}
public static void main(String[] args) {
Test test = new Test();
test.showTestOptionDialog();
}
}
---------- END SOURCE ----------
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
ver winxp home svc. pack 2
A DESCRIPTION OF THE PROBLEM :
When an item in joptionpane is doubleclicked, then [cancel] is clicked the value returned is NOT null, as it should be. Instead it is as if the user had selected the [ok] button because the returned value is not null.
Works fine when item is clicked only once!
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. double click item from joptionpane (list)
2. click cancel button or [x] from title bar.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Joptiondialog should return a null value when cancel button is clicked
ACTUAL -
joptionpane returns the item that was double clicked EVEN THOUGH cancel button was pressed after double clicking item
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.reflect.Array;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
class Test extends JFrame {
public void showTestOptionDialog() {
Object[] selectedItems = new Object[40];
for (int i = 0; i < 39; i++) {
selectedItems[i] = ("item :" + i);
}
String answer = (String) JOptionPane.showInputDialog(this,
"Double click on selected item then click cancel",
"Test Option Dialog", JOptionPane.WARNING_MESSAGE, null,
selectedItems, selectedItems[0]);
// if cancel clicked
if (answer == null) {
JOptionPane.showMessageDialog(null,
"Cancel clicked (answer should be null!), answer = " + answer,
null,
JOptionPane.INFORMATION_MESSAGE);
System.out.println("Cancel clicked, answer = " + answer);
// selectedItems = null;
return;
// else if OK clicked
} else if (answer != null) {
JOptionPane.showMessageDialog(null,
"OK clicked, answer = " + answer,
null,
JOptionPane.INFORMATION_MESSAGE);
System.out.println("OK clicked, answer =" + answer);
}
}
public static void main(String[] args) {
Test test = new Test();
test.showTestOptionDialog();
}
}
---------- END SOURCE ----------
- relates to
-
JDK-7138665 JOptionPane.getValue() unexpected change between JRE 1.6 and JRE 1.7
-
- Resolved
-