tags:

views:

423

answers:

2

How can I draw a filled rectangle in a java applet with half opacity/transparency?

+2  A: 

What API are you using? If you use Graphics from Java2D, when you create Color objects, you can add transparency to them as an alpha between 0 and 1.

Here's an old article on Java2D that has some examples

Uri
am using awt.Graphics.fillRect and awt.Graphics.setColor api calls.
A: 

Yup.

void foo(Graphics g) {
  g.setColor(new Color(.3f, .4f, .5f, .6f);
  g.fillRect(50, 50, 100, 100);
}