my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Positioning and size of GUI elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Positioning and size of GUI elements" Watch "Positioning and size of GUI elements" New topic
Author

Positioning and size of GUI elements

Nate Lockwood
Ranch Hand

Joined: Feb 22, 2010
Posts: 83
I've managed to get a GUI running and after lots of experimentation have it so that it displays and works almost as I desire.

The top Panel has a JList with scroll bars on the left and a JButton on the right.
1. The JButton is placed all the way to the right - I'd like to have it centered in the remaining space or just a bit to the right of the separator which is to the right of the JList.
2. The height of the pane appears to be half the height of the GUI . I'd like the height to be based on that needed for the JList.

The bottom panel is the same height as the top one and the buttons are all to the left. I would like this panel to be just the size that it needs to be for the 4 buttons.

I just don't understand the interactions and I must quite until next week.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> The bottom panel is the same height as the top one

you've set the panel's LayoutManager as a GridLayout, so that is what you get,
but you try to add the bottonPanel to BorderLayout.SOUTH


here's another classic:


you can't mix'n'match and hope they'll work.
study each LayoutManager and understand their individual strengths/purposes.


Nate Lockwood
Ranch Hand

Joined: Feb 22, 2010
Posts: 83
Thanks, I think you pointed me in the right direction. BTW I added the call to Super in desperation - it looked worse before!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Positioning and size of GUI elements
 
Similar Threads
Clearing a JList
urgent: retrieval of data from database to JList
Ref:JList and Selection problem
Button and Keyboard linking
JList and selection problem