• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transparent Diamonds.

 
Lori Nagel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been looking all over the internet for a tutorial that makes transparent diamonds, and I just can't find one. I could maybe put one together myself, but first I would need to find a working transparency tutorial for java. Most of them use a bunch of libraries I have never heard of, so they won't compile on my system.

So, does the standard jvm library come with some transparency library or something?

Also I found some paint Demo tutorial, but it says the api is depreciated? Is the Canvas depreciated? How can I make my applications use stuff that is current to Java 6 and above?
 
Stephan van Hulst
Bartender
Pie
Posts: 5912
66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lori, welcome to CodeRanch.

I'm assuming from the fact that you're posting in the Game Dev forum, that you're referring to graphics for diamonds, as in treasure.

First off, for graphical user interfaces in Java, you should primarily use Swing and not AWT. Instead of using a Canvas, use a JPanel.

Now, the easiest way to solve this is to have a gif or png file containing an image of your diamond sprite, and paint it using one of the Graphics.drawImage() methods inside the paintComponent() method of your JPanel. These formats support transparent pixels, and the drawImage() methods also take transparency into account.

If you're not familiar with Swing, check the Oracle tutorials. Find them through Google.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic