• Post Reply Bookmark Topic Watch Topic
  • New Topic

2 Simple JTextAreas with a button  RSS feed

 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every time i construct a JTextArea with say JTextArea(60,5) (60 cols and 5 rows) it does what it wants, and doesnt stick to the dimensions i give. I want a small window with 2 text areas and a button.



Can anyone please provide some simple code? Thanks.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm not sure, but layout managers overrule any preferred size you might set; so you'v to go with null layout to get it the way you want it, else conform to whatever layout you choose determines.
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's ok, i've got it now.

Thanks.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by miguel lisboa:
i'm not sure, but layout managers overrule any preferred size you might set; so you'v to go with null layout to get it the way you want it, else conform to whatever layout you choose determines.


No, you don't have to use a null layout - I'd actually never do that. You just have to understand how which layout works, and how to combine them to get the desired effect.

For example, I'd probably try a BorderLayout with area 1 in NORTH, area 2 in CENTER, and the button in a panel that's put into SOUTH. The ButtonPanel probably should have a FlowLayout or something - I always have to ask my coworkers for that...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!