• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help w/ displaying several .PNG files

 
Tom Collins
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks in advance.
Tom
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Craig Wood
Ranch Hand
Posts: 1535
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic