-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.2
-
x86
-
windows_nt
Name: skT88420 Date: 08/23/99
This is a follow-up up of Bug #ID 4107584, which wasn't fully
addressed. JComponents that have null borders, after being
serialized, receive borders.
Below is an example which demonstrates this behavior.
Note that the leftmost JTextField and JButton should *not*
have borders, since I had set them to null before serializing
them. Also note that this is a problem with other
JComponents -- including the composite JComboBox.
//Source Code Below
import java.awt.*;
import javax.swing.*;
import javax.swing.BorderFactory;
import java.io.*;
public class A extends JFrame
{
public A()
{
super();
final JPanel p = new JPanel(new FlowLayout());
final JTextField tf = new JTextField("foo");
tf.setBorder(null);
p.add(tf);
p.add(copyComponent(tf));
final JButton btn = new JButton("foo");
btn.setBorder(null);
p.add(btn);
p.add(copyComponent(btn));
setContentPane(p);
}
//Makes a copy of the source component using serialization
//As a side-effect, due to a bug, the source component border gets its border clobbered
private JComponent copyComponent(final JComponent source)
{
JComponent copy = null;
try
{
System.out.println("source's border prior to copying = " + source.getBorder());
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutput os = new ObjectOutputStream(baos);
os.writeObject(source);
os.flush();
os.close();
baos.close();
final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
final ObjectInput is = new ObjectInputStream(bais);
copy = (JComponent)is.readObject();
System.out.println("source's border after copying = " + source.getBorder());
System.out.println();
}
catch(Exception ex)
{
ex.printStackTrace();
}
return copy;
}
public static void main(String args[] )
{
A a = new A();
a.pack();
a.setVisible(true);
}
}
(Review ID: 94255)
======================================================================
- relates to
-
JDK-4192869 setBorder(null) requires updateUI() call to reset L&F border
-
- Closed
-