Knute Johnson wrote:
geoph521@gmail.com wrote:
I'm just learning swing with awt for making a ui, and i can't seem to
get it to look how I want.
layout:
__________________________
|Label : [Text Area ] |
|Label : [Text Area ] |
|Label : [Text Area ] |
|Label : [Text Area ] |
| [Button][Button] |
|_________________________|
|Text Area |
| |
| |
|_________________________|
My plan was to make the main JFrame use BorderLayout and put a grid of
the top 5 rows(each a seperate JPanel) and set the bottom part as the
text area.
I made a Jpanel for the top 5 rows that uses GridLayout with 5 rows and
1 column, I then tried to add seperate JPanels to each spot on the
grid, but they aren't showing up. Is there a way for me to use that way
to get this done or another way to set it up?
source of what im doing can be found here:
geoph521.googlepages.com/help.java
I hate to say it but this would be a good layout for GridBagLayout. You
wouldn't need a bunch of extra panels either.
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridy = 0;
// put a label and textarea here
++c.gridy;
// put your next row of label and textarea
// same for your buttons
.
.
.
++c.gridy;
c.gridwidth = 2;
c.fill = GridBagConstraints.HORIZONTAL;
// add your big textarea here
// pack it and show it
--
Knute Johnson
email s/nospam/knute/
Thanks, thats working a lot better than bafore.
My only problem now is that the text area starts as only being one line
tall, but expands every time a line break occurs. When it expands it
also ends up making the other components move around a bit. is there
any way i can keep it at a constant height?