简体   繁体   中英

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. The problem is that when I use the re dimensioned image it looks like this in a JButton.

I have already tried to create a emptyBorder in the JButton but that only remove the border of the button, not the icon. How can I remove it?

Edit: Just noticed that when the Window is not focused the border is not there? Image related

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

button.setFocusPainted( false );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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