This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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
Joined: May 02, 2002
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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com