• Post Reply Bookmark Topic Watch Topic
  • New Topic

horizontal weight of a component

 
Nadinha Jovan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am adding 3 components to a panel using grid bag layout. I would like the viewPN (see code below) to resize when the application window is resized but I cannot figure out how to do that. I want the viewPN to initially have size 1 row and 1 column and to accordingly change its size horizontally if the window is expanded. Here is the code I currently have in place. Thanks.
this.setLayout(gridBagLayout1);
this.add(durationPN, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(8, 2, 0, 10), 0, 0));
this.add(viewPN, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(8, 10, 0, 2), 0, 0));
this.add(editRowPN, new GridBagConstraints(0, 1, 3, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 2, 2, 2), 0, 0));
Thanks for your help.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Nadinha.
I hope this is what you want:

Setting viewPN to strech horizontally made the trick.
Notice that it is not useful to set editRowPN gridwidth to 3 because there are only tWo columns actually holding components in it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!