3

I am working on a homework so i am not asking for code, i am trying to make this by myself. by the way, i am stuck again with the GUI part and have little problems with code part. first things is about button size and image size. i didnt use methods for size of buttons just set the image as an icon for the button. but as you see below, buttons dont fit the image.

enter image description here

second thing is how can i first disable the icon and when user presses to button it will reveal the icon ?. and how can i embed 8 pictures in a loop? can i create an array for images... i appreciate if you can help me. and thanks anyway : )

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
quartaela
  • 2,579
  • 16
  • 63
  • 99
  • I think that you could post http://sscce.org/, – mKorbel Oct 23 '11 at 16:20
  • i couldn't find any place for post this. however i will continue to search. and thanks anyway : ) – quartaela Oct 23 '11 at 17:02
  • Edit your question to include your [sscce](http://sscce.org/); I've added related links in my [answer](http://stackoverflow.com/questions/7867087/gui-components-of-a-memory-game/7867721#7867721). – trashgod Oct 23 '11 at 17:12

1 Answers1

3

I'd start with How to Use Buttons. JToggleButton works well for this, as you can change the Icon in an ItemListener based on the button's selected state. Examples may be found here and here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045