Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with rows in JTextArea  RSS feed

 
Jack Drowder
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a snippet of code from a program I'm making:

The problem is, the JTextArea that's created has a "limited" number of rows - it seems you can still enter more lines than the "limit", but they don't show. I thought it was a problem with the JScrollPane but I'm not so sure...

Any suggestions?

Thanks!
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because JScrollPane uses the preferred size of its view component to determine whether or not scroll bars are needed. And since you've set it to a fixed value that value is used ever since.

What you probably want to do instead is call setRows on the JTextArea. That gives you a nice initial preferred size for showing the JScrollPane initially, but will also give you scroll bars when needed.
 
Jack Drowder
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the late reply - thank you very much!
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!