-
Bug
-
Resolution: Fixed
-
P3
-
8u60, 9
-
b116
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When showing an open or save dialog for a JFileChooser instance that has been read from an ObjectInputStream, the enter key does nothing in the resulting dialog. It works as expected before serialization.
REGRESSION. Last worked in version 7u75
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Instantiate a JFileChooser.
Serialize the JFileChooser instance using an ObjectOutputStream.
Deserialize the JFileChooser instance using an ObjectInputStream.
Show an open or save dialog for the deserialized JFileChooser instance.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Open/Save button should be the default button for the enter key. Showing the original JFileChooser produces the expected result. The enter key should do the same as it did before serialization/deserialization steps.
ACTUAL -
When showing the deserialized JFileChooser, the enter key does nothing.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
JFileChooser jfc = new JFileChooser();
//jfc.showOpenDialog(null);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(jfc);
oos.close();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
JFileChooser deserialized = (JFileChooser) ois.readObject();
deserialized.showOpenDialog(null);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Executing the following piece of code immediately after deserializing appears to solve the problem.
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
InputMap map = deserialized.getInputMap( JFileChooser.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
map.put(enter, "approveSelection");
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
When showing an open or save dialog for a JFileChooser instance that has been read from an ObjectInputStream, the enter key does nothing in the resulting dialog. It works as expected before serialization.
REGRESSION. Last worked in version 7u75
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Instantiate a JFileChooser.
Serialize the JFileChooser instance using an ObjectOutputStream.
Deserialize the JFileChooser instance using an ObjectInputStream.
Show an open or save dialog for the deserialized JFileChooser instance.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Open/Save button should be the default button for the enter key. Showing the original JFileChooser produces the expected result. The enter key should do the same as it did before serialization/deserialization steps.
ACTUAL -
When showing the deserialized JFileChooser, the enter key does nothing.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
JFileChooser jfc = new JFileChooser();
//jfc.showOpenDialog(null);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(jfc);
oos.close();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
JFileChooser deserialized = (JFileChooser) ois.readObject();
deserialized.showOpenDialog(null);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Executing the following piece of code immediately after deserializing appears to solve the problem.
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
InputMap map = deserialized.getInputMap( JFileChooser.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
map.put(enter, "approveSelection");
- relates to
-
JDK-8021253 JFileChooser does not react on pressing enter since java 7
-
- Resolved
-