-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
x86
-
windows_nt
Name: krT82822 Date: 03/09/2000
9 Mar 2000, eval1127@eng -- believe this is a dupe, but can't find the original bug. (may be symptom of bugs such as # 4145324)
orig synopsis: "Problem with deserializing JTextField: the TextField becomes unusable"
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)
If I serialize out a JTextField and then deserialize it back in, the following
problems occur:
If any text is entered into the JTextField that is longer than the width of the
field, scrolling back and forth through the JTextField does not work. The text
within the JTextField becomes garbled and unreadable.
The arrow keys, home, and end keys do not position the text properly.
In general the TextField becomes unusable if the number of characters (columns)
is greater than the width of the JTextField. I have tried putting the
JTextField in a JScrollPane and that does not fix the problem. A simple example
that shows this is:
------------------------------------------------------------------------
import javax.swing.*;
import java.io.*;
//A simple program that serializes out a JTextField, reads it back in, and
//places it on a JFrame
public class SerializationTest {
public void init() {
try {
JTextField testObject = new JTextField(10);
ObjectOutputStream out =
new ObjectOutputStream(new FileOutputStream("test.ser"));
out.writeObject(testObject);
ObjectInputStream in =
new ObjectInputStream(new FileInputStream("test.ser"));
Object fromFile = in.readObject();
JFrame testFrame = new JFrame("A deserialized JTextfield!");
testFrame.setSize(300,300);
testFrame.getContentPane().setLayout(new java.awt.FlowLayout());
testFrame.getContentPane().add((java.awt.Component)fromFile);
testFrame.show();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String args[]) {
new SerializationTest().init();
}
}
-------------------------------------------------------------------------
(Review ID: 101984)
======================================================================