Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Transparent Diamonds.

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?
Saloon Keeper
Posts: 12013
  • 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.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic