使 JPanel 不绘制其背景(透明) [英] Make a JPanel not draw its background (Transparent)

查看:24
本文介绍了使 JPanel 不绘制其背景(透明)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Java 中,是否有可能使 JPanel 跳过绘制其背景从而除了其上的组件之外是透明的?

Is it possible, in Java, to make a JPanel skip drawing its background thus being transparent except for the components on it?

推荐答案

setOpaque(false)

它会将背景绘制传递给其父级,后者可能会绘制自己的背景.

It'll pass off painting the background to its parent, which may draw its own background.

您可以进行屏幕截图,然后用它来绘制面板的背景.

You can do a screen capture and then use that to paint the background of the panel.

这篇关于使 JPanel 不绘制其背景(透明)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆