• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create empty but filled up cells in GridBagLayout  RSS feed

 
Ling Chung
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i want two label to be positioned as in a panel that's next to it and i want label1 to be at position gridx = 0; gridy = 0; and label2 to be in position gridx = 0; gridy = 3; how do i fill up gridy 1 and gridy 2?
Thanks alot!!
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ling,
If you have additional rows with components in those columns, you wouldn't have to do anything special. If however, there isn't anything else in other rows that will create the space you want, you'll need to use some sort of invisible component. javax.swing.Box.createGlue() is most likely what you'll want. You treat it like any other component except that it won't actually show up. It just takes up space. Coupled with GridBagConstraints, it can get your panel looking how you want it.
 
Ling Chung
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nice one thanks a lot!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!