The code below is just the GUI for a slot machine. Currently when play is clicked it displays the random number, I'm trying to make it so each random number displays an image in the GUI instead. For example if the random numbers were 2,2,3 it would display Cherry, Cherry, Bells. I started changing field1 to the image but realised I was on the wrong track as it would just display the same image not one allocated to a number. I've left in what I started doing.
Any tips on how to do it?
posted 2 years ago
1. Keep an Array of ImageIcons.
2. Generate your random number for each slot and then access the ImageIcon from the Array and add the icon to the label
Paper has not yet been outlawed – so let your Java Swing application print with wild abandon: JPDF