Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextArea Affecting Other Components  RSS feed

 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a JPanel that contains many components in a Gridbag Layout (9,2).
The majority of these components are simple JLabels-JTextFields. However, i would also like to add a JLabel-JTextArea. All works perfectly fine and displays beautifully. However, the JTextArea is not big enough for my needs. If i try and set its size in its constructor (eg new JTextArea(5, 30)) then this seems to affect the size of ALL my JLabel and JTextField components. Is this because i'm using a Gridbag layout and this tries to find a common size between components? If so has anyone any tricks to solve this, other than use some other form of layout manager?

Any tips or advice would be greatly appreciated. Many thanks!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on where the TextArea is to be positioned, one way might be:

create another JPanel jp, set as a borderlayout
jp.add(gridPanel,BorderLayout.NORTH);//or south
jp.add(textArea,BorderLayout.CENTER);
getContentPane().add(jp);
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!