aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Resizing TextArea() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Resizing TextArea()" Watch "Resizing TextArea()" New topic
Author

Resizing TextArea()

Richard Teston
Ranch Hand

Joined: Feb 12, 2002
Posts: 89
How can i resize textarea using gridbaglayout?


The Code is the Programmer
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Hi
this what you want is not so easy. Two days ago we had the same discussion. There I told the guy, that he should better take the null layout. Then it is possible to resize components.
In case of GridBagLayout, all the available space is provided by the LayoutManager. Only the manager can set the size. So the thing you have to do, is to change the size of the Frame. Maybe this is not that, what you want, but in my opinion, there is no better solution.
Here is a class, which implements the behavior I described.

Hope this helps

Rene
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
I am not sure exactly what you mean by resize but you could set the fill to GridBagConstraints.HORIZONTAL and the gridwidth to GridBagConstraints.REMAINDER when you add the text area and it should take up the rest of the row.
Take a look at this example . If you replace a text field with a text area, I think it does what you are asking.
ps In my opinion, null layout is never a valid option.
my .02
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
That's exactly what my example does. My TextArea takes all the available space. But I think, this is not what Richard wants. I think he wants to create an event, which changes the size of the TextArea (and maybe he wants to specify the size with a Dimension), if I understand him right. In my opinion, this is not possible with GridBagLayout.
The only way I see is null layout, but there are two facts:
I agree, null layout is a very bad solution.
I don't know, what is the advantage of the resizable TextArea? If it is inside of a ScrollPane, you are able to see all, you need.
Regards
Rene
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Resizing TextArea()