This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GridBagLayout resize issue

 
David Miranda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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 ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
David Miranda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic