
May 3rd, 2007, 08:40 AM
|
|
Registered User
|
|
Join Date: May 2007
Posts: 1
Time spent in forums: 43 m 48 sec
Reputation Power: 0
|
|
|
How do i do transparency in java?
Hi everyone, i'm having a problem with color transparency in java. I'm trying to make a semi-transparent color layer over the rest of the drawn things in a JPanel. I'm using double-buffering, so in a method render() I set a Graphics2D's color to a partially transparent color like this:
g2d.setColor(new Color(200,100,100, 100))
(The first three arguments are the RGB values, and the last one is the alpha value). Then i drew a filled rectangle over my buffer Image. In paintComponent(Graphics g), that Image is drawn onto the JPanel.
However, when the program runs, instead of a semi-transparent color over the rest of the JPanel's contents, it draws strange blocky colors... sorry if i'm not very specific :P
Anyways does anyone know how to do this right?
|