简体   繁体   English

透明的JFrame背景,但可见的内容

[英]Transparent JFrame background, but visible contents

I'm trying to make a desktop widget using Java, basically what it is, a clock that looks like the Sense Clock Widget from HTC android phones. 我正在尝试使用Java制作桌面小部件,基本上就是它,它看起来像是HTC android手机的Sense Clock Widget。

Everything is set, clock works and I have a background and clock hour/minute images. 一切设置完毕,时钟正常工作,我有背景和时钟时/分图像。 The only thing I need is to make the JFrame background transparent. 我唯一需要做的就是使JFrame背景透明。 The JFrame is undecorated and can be moved around by its content, just like any widget should act. JFrame是未修饰的,可以按其内容移动,就像任何小部件都应该起作用一样。

I need to figure out how to make the ugly JFrame background from grey to transparent but keep the contents opaque. 我需要弄清楚如何使丑陋的JFrame背景从灰色变为透明,但要使内容不透明。

frame.setBackground(new Color(0,0,0,0));

The frame is transparent but the content is visible. 框架是透明的,但内容可见。

结果的形象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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