This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am very new to Java, and I am trying to make a graphical Craps game. If you're familiar with Craps, then you know that there are about 40 different bets meaning there are 40 different places to put poker chips on the table. I'd like to show a poker chip on every bet location on the table where the player has actually placed a bet.
The best approach I can come up with so far is to: 1. Make 40 extended JPanel inner classes (inner to the actual extended JFrame class) 2. Override the paintComponent() method for each panel 3. Use the drawImage() method to paint the picture on the panel 4. Add every panel to the frame.
Then, as the user wins, loses, or places bets, I can turn the visibility off or on for the panels as needed.
The only other approach I can think of is constructing and destroying the panels as needed for each chip shown. I'm hoping there's a way to just say "if... show x picture at this location" and "if... remove x picture".
Am I way off track here? Is there a better way? Please help.
Welcome to the JavaRanch, Pete. You may have missed our naming policy when you registered, but we ask that people use a display name that is a first name and last name and not obviously fake. You can change your name here.