Resizing Contents Within Internal Frame

I have a JInternalFrame and within it I put a JTextArea which is inside of a JScrollPane. The code for that part is below:

txt =new JTextArea();

txt.setEditable(false);

txt.setPreferredSize(new Dimension(500, 40000));

scrollPane =new JScrollPane(txt);

BoxLayout paneLayout =new BoxLayout(getContentPane(), BoxLayout.Y_AXIS);

getContentPane().setLayout(paneLayout);

getContentPane().add(scrollPane);

this.addComponentListener(this);

I have code that listens for when the internal frame is resized and then I adjust the JTextArea accordingly. It initially resizes the way I want it to but then after I release the mouse button, The JtextArea resizes itself to fit the JInternalFrame it is in. How can I stop this so that it stays the size that I want it to change to?

[1027 byte] By [lesnaubra] at [2007-11-27 9:14:59]
# 1

Basically waht I am doing is trying to get the JTextArea to resize with the JInternalFrame and as text is displayed in te JTextArea, I need it to autoupdate the scrollbar so that the newest text is always shown. If there is a better way of doing this than the way I have started, please let me know how I could accomplish this. Thank you.

lesnaubra at 2007-7-12 22:03:39 > top of Java-index,Java Essentials,Java Programming...
# 2
That's actually a different problem and much easier. In the event where you handle the resize, get the length of the text (not that knowing really matters) and set the insertion point by calling setCaretPosition(...) with the length of the text in the text area. PS.
puckstopper31a at 2007-7-12 22:03:39 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks a lot. I knew there had to be an easier solution than what I was trying. I tried doing something similar to that before but I must have had some small detail wrong. Thanks again.
lesnaubra at 2007-7-12 22:03:39 > top of Java-index,Java Essentials,Java Programming...