开发者

Change the color of the Java Swing Component Focus indicator

开发者 https://www.devze.com 2023-03-24 09:51 出处:网络
开发者_如何转开发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
开发者_如何转开发

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?


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消