-
Bug
-
Resolution: Fixed
-
P4
-
1.4.1, 1.4.2
-
tiger
-
x86
-
linux, windows_xp
Name: jk109818 Date: 08/07/2003
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)
FULL OS VERSION :
Linux checkmate 2.4.18-19.8.0 #1 Thu Dec 12 05:39:29 EST 2002 i686 i686 i386 GNU/Linux
(bug appears on many other 1.4.1 JDK versions)
A DESCRIPTION OF THE PROBLEM :
Serializing a JFrame constructed from Boxes (using the Swing Box class) with the java.beans XML serialization does not work properly. Serialization works if the JFrame contains panels, but not if the JFrame contains boxes. When the JFrame containing a box is written, InstantiationExceptions are thrown
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the attached code
Run
java SimpleFrame
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A properly serialized Frame object in the file SimpleFrame.xml
ACTUAL -
Frame not saved properly.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
% java SimpleFrame
java.lang.InstantiationException: javax.swing.Box
Continuing ...
java.lang.Exception: discarding statement JPanel0.add(Box0);
Continuing ...
java.lang.InstantiationException: javax.swing.Box
Continuing ...
java.lang.Exception: discarding statement JRootPane$10.addLayoutComponent(Box0, "Center");
Continuing ...
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.event.ActionListener;
import java.beans.*;
import java.io.*;
public class SimpleFrame {
public void doOne() {
System.out.println("One button pushed");
}
public void doTwo() {
System.out.println("Two button pushed");
}
public JFrame makeUI() {
JFrame f;
JButton b1, b2;
JLabel l3;
Box vBox;
f = new JFrame("SimpleFrame");
f.setSize(400, 300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
vBox = Box.createVerticalBox();
b1 = new JButton("One");
b1.addActionListener((ActionListener)
EventHandler.create(ActionListener.class, this, "doOne"));
b2 = new JButton("Two");
b2.addActionListener((ActionListener)
EventHandler.create(ActionListener.class, this, "doTwo"));
l3 = new JLabel("Separator");
vBox.add(b1); vBox.add(l3); vBox.add(b2);
f.getContentPane().add(vBox);
f.setVisible(true);
return f;
}
public static void main(String args[]) {
SimpleFrame me = new SimpleFrame();
try {
XMLEncoder e = new XMLEncoder(new BufferedOutputStream (
new FileOutputStream("SimpleFrame.xml")));
e.writeObject(me.makeUI());
e.close();
} catch (IOException e) { e.printStackTrace(); }
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't use Boxes. Not a good workaround.
(Incident Review ID: 193799)
======================================================================
- relates to
-
JDK-6582164 JavaBeans tests should be open source
- Resolved