java 创建透明面板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/258023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:40:04  来源:igfitidea点击:

Creating a transparent panel

javapaneltransparent

提问by sv_in

I need to create a panel which should be invisible but the components inside it (for example, JTextArea, JButton, etc.) should be visible. When I click on the invisible panel, it should become visible.

我需要创建一个应该不可见的面板,但它里面的组件(例如,JTextArea、JButton 等)应该是可见的。当我点击不可见面板时,它应该变得可见。

I can only use JRE 1.4 and nothing more than that. :(

我只能使用 JRE 1.4,仅此而已。:(

Any idea how to create such a transparent panel???

知道如何创建这样一个透明面板吗???

回答by Peter

Transparancy is controlled with

透明度受控制

setOpaque(false)

回答by gizmo

JComponent.setOpaque(false)is the way to go.

JComponent.setOpaque(false)是要走的路。