Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Gridbag Layout Problem  RSS feed

 
Thomas Moore
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I like java very much.

I'm trying to do a card game, a game of pairs.

In the options to the game the user will select the number of cards.
That number will then be multiplied by two to get the number of pairs.
The number of cards will laid out in a table like fashion.

The cards will be randomly placed and there will always be two of one card.The problem lies in putting the components into a Structure. I've come up with several layouts and I am wondering which one to use. Grid,Spring,Gridbag or Flow. Please Help, and help would be gratefully received.

Thanks

Tom
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GridLayout(4,3) seems ideal for the given drawing

if this is for a 'memory match', you can use JLabels, JButtons etc and their icon property
button.setIcon(icons[x]);//where icons[] is a shuffled array of icons
or
button.setIcon(null);//blank
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!