File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes I can't make my JTextArea Scrollable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "I can Watch "I can New topic
Author

I can't make my JTextArea Scrollable

Sarang Bokil
Greenhorn

Joined: Oct 27, 2010
Posts: 5
Hi,

I am supposed to display data from a file into a JTextArea.
To make it scrollable, I put it into a JScrollPane, but as soon as I input the data read from the file into JTextArea, the text goes out of bounds.
If i don't put anything in the JTextArea, and enter text from keyboard, it remains scrollable, but if I set text read from a file, it's scroll doesn't work.

Please help.

Regards,
Sarang
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
could depend on the layoutManager of the scrollPane's container

try giving the scrollPane a size
scrollpane.setPreferredSize(new Dimension(400,300));//where 400,300 is anything smaller than the likely size of the textArea
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: I can't make my JTextArea Scrollable
 
Similar Threads
i am not able to know what the problem is
How can I show new text in JTextArea while program is executing?
How can I display the contents of a file
JText Area..searching and replacing text
Is my problem because of 'StringBuilder'? Or do I need to some memory management (somehow)?