jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes Help w/ displaying several .PNG files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help w/ displaying several .PNG files" Watch "Help w/ displaying several .PNG files" New topic

Help w/ displaying several .PNG files

Tom Collins

Joined: Mar 13, 2006
Posts: 10
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.

Me fail english?! That's unpossible!
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

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.

[How To Ask Questions On JavaRanch]
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link: http://aspose.com/file-tools
subject: Help w/ displaying several .PNG files
It's not a secret anymore!