• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Help w/ displaying several .PNG files

 
Greenhorn
Posts: 10
  • 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
 
Bartender
Posts: 9587
13
Mac OS X Linux Windows
  • 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.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Beauty is in the eye of the tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!