Question

I am just wondering... I saw many examples but they all dedicated for Java 7 only :( So my question is:

Is there a more or less optimal way to make transparent JWindow (or undecorated JFrame) with Java 6?

Was it helpful?

Solution

Making a JWindow translucent is very simple. Window translucency has been available for as long as I can remember, even in a library as archaic as AWT.

The Swing JWindow is a subclass of the java.awt.Window class, which defines a method called setOpacity. All you need to do is pass a float value between 0 and 1.

Here's the most basic example imaginable:

JWindow window = new JWindow();
window.setSize(300,200);
window.setOpacity(0.5f); //this will make the window half-transparent

For a fully transparent window, call window.setOpacity(0.0f)

There are many more things you can do with the built in functionality. Read up on the subject here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top