permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes JPanels with different content should have the same size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanels with different content should have the same size" Watch "JPanels with different content should have the same size" New topic
Author

JPanels with different content should have the same size

Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
Hi,
I have a problem with some panels. They have some buttons, textFields and so on. Thats why the size of the panels are different and it looks bad. If there is space left, the panel should be big as the biggest panels of all. I cant use an absolute Layout. So how can I make them the same size? I think it is a design question...
Please help
Thanks a lot
regards Kay
[ February 19, 2003: Message edited by: Kay Tracid ]
[ February 19, 2003: Message edited by: Kay Tracid ]
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
GridLayout. Not knowing how your screen looks doesn't help. If you can't use that for whatever reason. You could set the maximum size and minimum size to the same for all. They won't resize when you enlarge the window though.
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
i have still the problem. can sombody help? here is the code:

[ February 22, 2003: Message edited by: Kay Tracid ]
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
maybe the sourcecode helps to find a solution?
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
could someone give me a hint please?
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Have you tried putting them in a GridLayout? You are using GridBagLayout in your code example.
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
i tried, but i failed. if i use gridlayout the label, textfield and button is centered in the middle. that looks bad.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Real quick here is one way to do it.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Here is another way of doing it. You would have to find the largest size if doing it this way.
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
Thanks a lot. I will try to use this way. I dont know the largest label, but I will try to find that out.
Thanks for your help
 
Consider Paul's rocket mass heater.
 
subject: JPanels with different content should have the same size