Resizing JTextArea
843804Dec 29 2004 — edited Dec 30 2004Can someone give me some pointers on the best way to have a JTextArea automatically resize itself to fill the container when its container size changes?
I have an app that has three panels. The center panel has a JTextArea that I would like to shrink and grow based on the size of the JFrame holding the panels. Panel one is NORTH, panel two is CENTER and panel 3 is SOUTH. Panels one and three I want to keep the same vertical size while panel 2 shrinks and grows.
I've tried adding a ComponentListener to listen for comonentResize then setRows and setColumns on the JTextArea to no avail:( I've tried Using a GridBag Layout manager with GridBagConstraints fill = GridBagConstraints.BOTH, but that didn't do it for me either.
I'm thinking this is a fairly rudimentary task that I'm missing the obvious on, but those are always the hardest to find.
Does anyone have any example code that produces this functionality for a JTextArea?
Thanks
G