Resizing JTextArea

First, I'm wondering if anyone else has experienced the following problem:

When a user resizes a JFrame, an editable JTextArea component does not display its contents properly. Specifically, the caret does not change position, but the displayed text does not even show the caret. The user can use an arrow key and everything is then fine. The behavior is sporadic, sometimes everything works.

The program in which this occurs is too large to show the code, and I'm hoping I don't have to manufacture an example showing this. At any rate, the JTextArea is inside a JScrollPane which in turn is a component of a JSplitPane. The JTextArea has a CaretListener and also a DocumentListener, although I don't see how this could have any bearing on the problem.

Thanks in advance for any help.

[814 byte] By [johnxmatha] at [2007-10-2 21:22:36]
# 1

maybe a focus issue?

try adding a componentListener to the frame and in componentResized(..)

SwingUtilities.invokeLater(new Runnable(){

public void run(){

textArea.requestFocusInWindow();

}});

but this will take the focus away from any other component that had the focus

prior to the resize

Michael_Dunna at 2007-7-14 0:32:59 > top of Java-index,Desktop,Core GUI APIs...
# 2
Michael,Thanks for the suggestion. The text area already has the focus when the problem occurs, so I didn't think requesting the focus would make any difference. Sure enough, it didn't.
johnxmatha at 2007-7-14 0:32:59 > top of Java-index,Desktop,Core GUI APIs...