wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes which layout manager to use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "which layout manager to use" Watch "which layout manager to use" New topic
Author

which layout manager to use

srilatha malip
Greenhorn

Joined: Feb 08, 2001
Posts: 21
Hi all,
I've 4 comboboxes, 4 labels for comboboxes and one text field and two buttons. I am planning to add all these to panel. I'll add panel to a frame. I'm planning to use borderlayout for frame. Which layout manager will be suitabel for panel, if I add the above specified components to it. I don't want to use absolute positioning...since components will get disturbed with resizing. I think even flowlayout will not be appropriate. All suggestions will be appreciated.
Thanks,
Srilatha.
Ameet Choughule
Greenhorn

Joined: Feb 08, 2001
Posts: 4
Hi Shrilata,
I too faced a similar problem and being an anateur I found layout managers a hopeless part of Java.
But the panelname.setLayout(null) is ideal and gives great looks as you can place components where desired and resizing of frame/window does not affect the components.
The components can be placed by using setBounds as in
Yourcomponent.setBounds(x,y,width,height) and then adding the component to the panel by saying panelname.add(yourcomponent)
Regards,
Ameet
sashkamal
Greenhorn

Joined: Feb 05, 2001
Posts: 4
hi srilatha,
can u tell me how u are going to place the components.
i suggest u to use separate panel for combobox, separate panel for label and use vertical layout(avialable free in the net).
Add the two panels to an outer panel in east and west.in another panel add the textfield to the center.
Add the two buttons in a separate panel using flowlayout.add this panel and textfield panel to another panel in north and south.
Add the 2 outer panel to an another outer panel in north and south.
Add this panel to the frame in center.
If u want the vertical layout class, mail me to this id
-sashkamal@lycos.com
bye.

------------------
sashkamal


sashkamal
Helmut Lerch
Ranch Hand

Joined: Feb 11, 2001
Posts: 48
Originally posted by srilatha malip:
Hi all,
I've 4 comboboxes, 4 labels for comboboxes and one text field and two buttons. I am planning to add all these to panel. I'll add panel to a frame. I'm planning to use borderlayout for frame.
Thanks,
Srilatha.

Hi,
I would add each Combobox with its Label to a Panel with a FlowLayout. I asume the two buttons are a "Ok" and a "Cancel" Button. So I would add this two buttons also to a panel with a
Flowlayout. For the main Panel I would use a GridLayout with five rows. Next I would add all Panels and the TextField in the desired order to the main Panel. Or perhaps you like to seperate the Ok/Cancel Panel from the oders by using another Panel with a BorderLayout (adding the Ok/Cancel Panel to NORTH and the GridLayout Panel to CENTER).
I am also an amateur. It tooks some time to unterstand how to use the LayoutManagers and to recognice the different advantages but i think its worthy to learn.
Hope this helps.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: which layout manager to use
 
Similar Threads
JFrame, JPanel and sizes
Am I using repaint correctly?
about Layout Manager
which layout manager
JTable