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

Resizable JTextArea  RSS feed

 
Levente Szekrenyes
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to know how to allow the user to resize some of the JTextAreas. I have put these into a JFrame, with a GridBagLayout, but then I can't resize them. Is there any way to do this?
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
try to put a JScrollPane around your JTextArea and add the JScrollPane to your JFrame.
Greetings
Rene
 
Levente Szekrenyes
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I did that. That's not the problem. I want the user to be able to resize the actual component (the JTextArea) like setSize() does...
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I understand. Maybe the GridBagLayout is a bit wrong, because the layout itself will set the size of your component. In your case, I would prefer to take a null layout. Then it should be possible to set the size of your JTextArea.
Just call:
frame.getContentPane().setLayout(null);
JTextArea textArea = new JTextArea();
textArea.setSize(100,100);
frame.getContentPane().add(textArea);
textArea.setSize(200,100);
Hope this helps
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!