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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.