Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,159 Points

JavaFX GUI playing card program. Showing back of card and then flipping to card face.

I am assigned to make a simple JavaFX program - a "card war" where three cards are shown face down. The user taps (mouse click) on the middle card and the right card is flipped and shown, and then taps again and the left card is. The image is then reset. The middle card remains face down (like a deck from which cards are being drawn.)

I can code the reset and the random selection of three cards. I am not sure how to code the "flip" from back to face on the right and left cards. I have a sense that the image is being replaced (the image of the back of the card is replaced with the card face image) but I don't know how to get started with coding the swap of card back for card face. The cars are gif images numbered 101 to 155, 155.gif is the card back.

Any ideas how to do this? I can post code if needed but since this is the crucial step in the game I am not sure it would be much help. Thanks.