• 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

GridBagLayout resize issue

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Im trying to left-orient a JLabel and JList in a GridBagLayout panel thats in a split pane.

I'm using a GridBagLayout because I'm trying to left orient everything in the panel...I tried to use a BoxLayout but everything was center-oriented, the only way I found to get the Label to become left-oriented in the pane was to increase the size of the label to size of the surrounding pane (I dont want to hard code the size of the label )

I want the the GridBagLayout panel to resize correctly when the split pane is pulled up and down....but when I move the drag the split pane up towards the list, the JList gets crushed...not shrunk like expect...crushed and center-oriented in the panel

Please tell me what I'm doing wrong!

Also, if anybody can tell me how to left-orient components in the surrounding pane without using a GridBagLayout or hard-coding the component size, that'd be great.

Thanks,

David

Here's my code:



[ June 30, 2007: Message edited by: David Miranda ]
[ July 01, 2007: Message edited by: David Miranda ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
David Miranda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mike

Does anyone know why the GridBagLayout code crushed the contents when the panel resize made it smaller?

Thanks
[ July 01, 2007: Message edited by: David Miranda ]
 
David Miranda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EUREKA!

Well, the fix was remarkably easy.

Turns out that I needed to set the constraints fill to GridBagConstraints.BOTH for the component that I want to fill the remainder of both the horizontal and vertical space.

Here's the code for those who may come after with this problem (I've seen at least a half-dozen before me using search)


[ July 01, 2007: Message edited by: David Miranda ]
reply
    Bookmark Topic Watch Topic
  • New Topic