• 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

GridLayout

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having problems on layouts.
I am trying to use GridLayout(5,4)

p.add(button1)
p.add(b2)
p.add(b3)
p.add(b4)

Can I specify where the button 2 will be placed? I would like to place button3 in colum 2, row2.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The elements of GridLayout are layed left-to-right (or right-to-left, like its javadocs mention) and top-to-bottom. So to put something in column 2 of row 2, you need to fill up row 1 first, and then column 1 of row 2. If you don't have real GUI elements for those places, you can use JLabel with no text to keep those spots empty.

An alternative would be to use the (more complicated) GridBagLayout class.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic