2

In any program, or at least most, when you select a button or anything, there is a selection box made of lines which are made of dots.

How do you get rid of that box?

The reason why I want to do this is because I have a button with an image, no contentFill, no borders, and it looks very awkward when selected.

syb0rg
  • 8,057
  • 9
  • 41
  • 81
Ted
  • 629
  • 2
  • 8
  • 19

1 Answers1

7

Make the button or component non-focusable by calling its setFocusable(...) method:

myButton.setFocusable(false);

Edit
... or maybe even better:

myButton.setFocusPainted(false);

This way the component can still get the focus if need be, but just doesn't show the focus border.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373