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

Tags: , , , ,



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

Answer

Just noticed that when the Window is not focused the border is not there?

button.setFocusPainted( false );


Source: stackoverflow