aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes GUI Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI Question" Watch "GUI Question" New topic
Author

GUI Question

Mark Henderson
Greenhorn

Joined: Mar 05, 2010
Posts: 1
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

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Jul 26, 2007
Posts: 10451
    
    8

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


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI Question