即使将 Border 设置为 EmptyBorder,JButton 的边框也不会消失
我正在 Mac 上使用 Eclipse 设计 GUI,我想让 JButton 仅显示我设置的图标。它在 Mac OS 上看起来很好,但是当我将其导出到 jar 文件并在 Windows 操作系统上使用时,JButton
看起来像这样:
边框均为 EmptyBorder
。
我做错了什么?如何让后面的方块消失?
I am designing a GUI using Eclipse on Mac, and I want to make the JButton
to display only the Icon I set. It looks fine on Mac OS, but when I export it to a jar file, and rut in on Windows OS, the JButton
looks like this:
The borders are all EmptyBorder
.
What did I do wrong? How can I make the square at the back go away?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要正确回答此问题,很可能需要 SSCCE。无论如何,我相信您会想要调用 JButton 实例上的“noreferrer">
setContentAreaFilled(false)
。这应该有效地消除“正方形”。然而,值得注意的是,调用此函数的确切行为因组件和 L&F 的不同而不同。
To answer this question correctly, an SSCCE will most likely be required. Anyway, I believe that you'll want to invoke
setContentAreaFilled(false)
on yourJButton
instances. That should effectively remove the "square".However, it is important to note that the exact behavior of calling this function varies on a component-by-component and L&F-by-L&F basis.
1)无法重现这一点,如果没有看到您为此编写的代码就很难说,
2)因为您触摸了 XxxButtonUI,这实际上是与本机操作系统相关的问题,外观和感觉用于此目的
3)什么如果你重写 MetalButtonUI 会发生什么吗?
4)是否有半透明背景,或带有某种颜色,或...
1) can't to reproduce that, too hard to say without seeing code that you wrote for that,
2) because you touched XxxButtonUI, and this is really Native OS rellated issue, which Look and Feel is there used for that
3) what happens if you override MetalButtonUI?
4) is there transulcent background, or with some Color, or ...