Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I can't make my JTextArea Scrollable

 
Sarang Bokil
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic