Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can't change rows or columns in JTestArea  RSS feed

 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I have a JTextArea I've added to a JScrollPane (the scroll pnae is added to a JFrame). I want to be able to dynamically change the number of rows and/or columns shown in the text area. When I created it I used the (String, int, int) constructor. The displayed area was the right number of rows but too many columns. I added a button to change the number of rows and columns (eventually these will be menu items) and used the setRows and setColumns methods. Neither way worked. The textArea stayed exactly the same size. I tried all sort of different combinations too. validate(), revalidate(), repaint(), and many more. Even tried different Layout managers too with no success.
If anyone has any idea I'd greatly appreciate it.

Thanks

Dave
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
figured it out. Had to validate() the JFrame itself, not the JScrollPane and not the JTextAre. It works great now.
hope someone else can learn from my fumbling.

Dave
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!