File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes help with Layout  consideration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help with Layout  consideration" Watch "help with Layout  consideration" New topic

help with Layout consideration

Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hi All!
im a Graphics designer before a Java programmer , therefor
i need to layout my interface in a very flexibility way.
when i extending a component i use setLayout(null) and setBounds() to path the component to very specific place on the extended component.
i wonder if you (all) can suggust me a way that can provide flexbility
in pathing the components , for example: the BorderLayout() can be pathing to a specific place by setting
add(com,BorderLayout.East) but it has only 5 places and not according to my requests, how can GridLayout path? and the other manager?
marilyn murphy
Ranch Hand

Joined: Aug 28, 2001
Posts: 84
I think GridBagLayout is the most flexible, but so far I have not used it. I also have been using null layouts.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
It depends on what you want and need. Multiple panels with different layouts works great. The key is knowing how each layout reacts and what combination to use. I don't use null layout because when you expand the viewing area or the change resolution you often get ugly results. I have had good results using BoxLayout with multiple panels stacked. GridBagLayout, BorderLayout and FlowLayout they all have their place.
Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hi guys!
ok...but what about pathing them to a specific position in the managet? only in BorderLayout i can do it ny East,South etc..
how can i do the samr think with the others???
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
I am not sure what you mean. I generally look at the screen mock up and break it into logical pieces. For instance you may have a header area, a group of aligned text fields and labels, another grouping of components and at the bottom buttons. I may decide to create a separate panel for each logical group. All of those I decide to place on the main window using a vertical BoxLayout. The header panel I use FlowLayout centered. The text/label fields GridBagLayout. The buttons FlowLayout centered.
It all comes down to knowing how each layout works and acts when you change the size of the window. If you use the layout managers correctly the components aren't placed in an absolute position they are placed relative to others and the layout manger takes care of it. If you use the null layout, when you resize a window it can really look bad. So you decide i'll make it so it can't be resized. Then the resolution is changed and it looks bad again. Play with the layout managers putting various components on them and see what happens. You will get to the point where you can look at screen mock ups and know where to break it up and what layout to use. There is no easy answer.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Here is a tutorial to help you understand:
Normaly you need to use more than one to get any complex layout.
For instance you can take a Frame and give it a GridLayout of 2 by 3. Then EACH of those 6 spots can have a Panel in them. Each of the Panels can then have whatever LayoutManager that you want IT to have, etc. Stacking containers gives you LOTS of combinations of ways to format the screen. It just depends on how clever and artistic you are in designing the arrangements.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: help with Layout consideration
It's not a secret anymore!