• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Positioning and size of GUI elements

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 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
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I think you pointed me in the right direction. BTW I added the call to Super in desperation - it looked worse before!
 
I've been selected to go to the moon! All thanks to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic