Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which layout manager to use

 
srilatha malip
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Helmut Lerch
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic