Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the color of the Java Swing Component Focus indicator

I have a JPanel with a JButton, JTextField and a JTable, and the TAB key traverses these components as expected with a little black box drawn around the component (or cell in case of the JTable) that has focus. How can I change the color of the black-box focus indicator?

like image 228
splatek Avatar asked Oct 10 '22 09:10

splatek


1 Answers

The selection appearance is under the control of each component's UI delegate, discussed in How to Set the Look and Feel.

As a concrete example, on certain L&Fs, you can override the default value when your program starts up:

UIManager.put("Button.focus", Color.red);
like image 53
trashgod Avatar answered Oct 13 '22 11:10

trashgod