Solved

swing gui layout issues - any help or advice?

Posted on 2006-07-03
8
202 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 48
Fibonacci challenge 11 84
base64 decode encode 12 97
Java and GPO 11 47
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)
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

762 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

18 Experts available now in Live!

Get 1:1 Help Now