简体   繁体   中英

How to make JFrame transparent in JDK 1.6?

In JDK 1.7 I use setUndecorated(true); and setBackground(new Color(0, 0, 0, 0)); to make my frame transparent.

This works perfectly but when I change the project to 1.6 this same code just makes the frame its original blue-ish color. I don't want to make my form Opacity lower as in alpha transparent. I want to have it more like a splash screen, where GD draws SOLID non opacity lines but the surrounding is completely click-through and transparent.

What is the code in 1.6 to do this?

See this tutorial to understand how to make a JFrame Transparent

http://blogofjavacrazy.blogspot.in/2007/03/transparent-window-in-java.html

/////Edited Part//////

I stumbled upon a neat little hack that instead of actually being transparent, it takes a screenshot and adds that little segment as the background.

See this Link:

http://onjava.com/pub/a/onjava/excerpt/swinghks_hack41/index.html

In jdk 1.6 I use setUndecorated(true); setBackground(new Color(0, 0, 0, 0)); to make my frame transparent. This works perfectly but when I change the project to 1.6 this same code just makes the frame its original blue-ish color.

maybe there is this issue As of the Java Platform, Standard Edition 6 (Java SE 6) Update 10 release, you can add translucent and shaped windows to your Swing applications.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM