wood burning stoves 2.0
The moose likes Game Development and the fly likes Transparent Diamonds. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Transparent Diamonds." Watch "Transparent Diamonds." New topic

Transparent Diamonds.

Lori Nagel

Joined: Sep 10, 2012
Posts: 1
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

Joined: Sep 20, 2010
Posts: 4624

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.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
I agree. Here's the link: http://aspose.com/file-tools
subject: Transparent Diamonds.
It's not a secret anymore!