• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI Question

 
Mark Henderson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to make a memory card game but im not sure how to get started with the GUI part. I have made the frame and the content pane etc and have a working menubar but as to how I would display 40 cards im not sure. I was thinking of using a grid layout but how would I display the images the correct size and what would happen when the image is actually clicked?? Any help would be greatly appreciated.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in a simple memory card game, say 16 'cards', it could go something like this

JPanel set as GridLayout(4,4), also setting the gaps
8 images
Image array [16], the images are duplicated
Image array shuffled
16 JButtons (array) added to the JPanel

when program runs, 16 blank buttons appear
click a button and you set the button's icon to the corresponding image array index
repeat for a second button, which triggers a timer to check if the images are the same
if not, set both button's icons to null

should be enough to get you going


 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
Welcome to the Ranch.

We have a forum dedicated to UI where UI related questions should be asked. I will move this thread over there for you.
In the meanwhile please do check out http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic