Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Resizing TextArea()

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can i resize textarea using gridbaglayout?
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic