[英]How to make JFrame transparent in JDK 1.6?
In JDK 1.7 I use setUndecorated(true);
在JDK 1.7中,我使用
setUndecorated(true);
and setBackground(new Color(0, 0, 0, 0));
和
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. 这可以完美地工作,但是当我将项目更改为1.6时,相同的代码只会使框架变为原始的蓝色。 I don't want to make my form Opacity lower as in alpha transparent.
我不想像Alpha透明那样降低窗体的不透明度。 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.
我想让它更像一个启动屏幕,其中GD绘制SOLID非透明线,但周围环境完全是点击后透明的。
What is the code in 1.6 to do this? 1.6中执行此操作的代码是什么?
See this tutorial to understand how to make a JFrame Transparent 请参阅本教程,以了解如何使JFrame透明
http://blogofjavacrazy.blogspot.in/2007/03/transparent-window-in-java.html 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 http://onjava.com/pub/a/onjava/excerpt/swinghks_hack41/index.html
In jdk 1.6 I use setUndecorated(true);
在jdk 1.6中,我使用setUndecorated(true); setBackground(new Color(0, 0, 0, 0));
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.
这可以完美地工作,但是当我将项目更改为1.6时,相同的代码只会使框架变为原始的蓝色。
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. 从Java平台标准版6(Java SE 6)Update 10发行版开始,您可以在Swing应用程序中添加半透明和成形的窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.