更改Java Swing组件焦点指示器的颜色 [英] Change the color of the Java Swing Component Focus indicator

查看:197
本文介绍了更改Java Swing组件焦点指示器的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JButton,JTextField和一个JTable的JPanel,TAB键遍历这些组件,如预期的那样,围绕组件(或JTable的单元格)绘制的黑盒子有焦点。如何更改黑盒焦点指示器的颜色?

解决方案

选择外观是在每个组件的UI委托的控制下,在 如何设置外观

作为一个具体的例子,在某些L& Fs上,当程序启动时,你可以重写默认值:

pre code> UIManager.put(Button.focus,Color.red);


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

这篇关于更改Java Swing组件焦点指示器的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆