简体   繁体   English

如何使用 Eclipse 删除 JButton 中图标的边框?

[英]How to remove the border of an Icon in a JButton using Eclipse?

first time making a question here.第一次在这里提问。 First of all, Eclipse (as far as I'm aware of) don't let you re dimension images through the design tab directly so to solve this I made a method that convert the icon from ImageIcon to image, re dimension it and then convert it back.首先,Eclipse(据我所知)不允许您直接通过设计选项卡重新调整图像尺寸,因此为了解决这个问题,我制作了一种方法,将图标从 ImageIcon 转换为图像,重新调整尺寸,然后转换回来。 The problem is that when I use the re dimensioned image it looks like this in a JButton.问题是,当我使用重新调整尺寸的图像时,它在 JButton 中看起来像这样

I have already tried to create a emptyBorder in the JButton but that only remove the border of the button, not the icon.我已经尝试在 JButton 中创建一个 emptyBorder ,但只删除按钮的边框,而不是图标。 How can I remove it?我怎样才能删除它?

Edit: Just noticed that when the Window is not focused the border is not there?编辑:刚刚注意到当 Window 未聚焦时,边框不存在? Image related图片相关

刚刚注意到当 Window 没有聚焦时,边框不存在?

button.setFocusPainted( false );

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

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