Java Graphics2D transparent background

You can construct a Color object by specifying a transparency. For example the following code constructs a RED color with 50% transparency

Color c=new Color(1f,0f,0f,.5f );

You can call the constructor of Color in the following way:

Color c = new Color(r,g,b,a);

where a is the alpha (transparency) value.

As with all Java classes, you can find this information in the official API:

It's a really good resource and can spare you waiting for an answer on here.