Solved

swing gui layout issues - any help or advice?

Posted on 2006-07-03
8
214 Views
Last Modified: 2010-03-31
Hi,

I'm currently writing a swing gui, which requires the following characteristics:

- a menu bar at the top of the frame
- 3 panels, with the top panel the largest of the three panels, the middle panel a set height, and the bottom panel large enough to fit a textfield and 2 buttons
- resizeable, and maintain the predefined size proportions for each panel

Which layout manager is best to use to achieve the above characteristics?

Any advice or help is appreciated.

Thanks
0
Comment
Question by:nhay59
  • 5
  • 2
8 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 17032104
BorderLayout.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 17032116
The menu is attached to the mainframe and independent of the layout.

Put the 3 panels at Notrh, Centre and South resp.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 17032120
North of course.
0
 

Author Comment

by:nhay59
ID: 17032197
Hi,

Thanks for the reply. Is it possible to define set sizes for the panels, in order to stop the center panel from being the largest one?

Whenever I've used BorderLayout before, the North and South panels have been big enough to fit all the components and the center panel has simply filled all the remaining space. I need the top/North panel to be the largest, in order to fit images that are chosen from the open item within the menu bar.

Thanks for the help.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 24

Accepted Solution

by:
sciuriware earned 300 total points
ID: 17032939
You could put a (vertical) split panel in the centre and put the first 2 panels in there.
I never did it, but I read somewhere that the split panel keeps the proportions.

;JOOP!
0
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
ID: 17033870
you'd need two BorderLayout Panels

the first would contain:
   - the top panel in CENTER
   - add second panel in SOUTH

the second would contain:
   - middel panel at NORTH
   - bottom panel at SOUTH

And set the height of the middle panel use setPreferredSzie()
0
 

Author Comment

by:nhay59
ID: 17037886
Hi,

Thanks for the replies. I've managed to get it to work with a combination of both possible answers. I put the main image viewing panel as Center within a BorderLayout, and used a split pane for the bottom two panels, with a position as South in a BorderLayout.

Thanks for the help.
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 17040273
Great! :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Requested array size exceeds VM limit 3 85
Java JRE greater than 1.6 5 51
eclipse shortcuts 9 45
Spring Framework HTTPSession management 1 24
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now