简体   繁体   English

Java JButton鼠标悬停在颜色上

[英]Java JButton mouse over color

I have a Java Swing application that's using "system" look and feel (as i'm using Windows, i'm getting "native Windows" controls in my app). 我有一个使用“系统”外观的Java Swing应用程序(当我使用Windows时,我的应用程序中出现了“本机Windows”控件)。 Now, for "branding" reasons i'm trying to enforce particular color on my buttons but i have a problem. 现在,出于“品牌”的原因,我试图在按钮上强制使用特定的颜色,但是我遇到了问题。 I prefer using UIManager but i can't find any property that would let me choose "button mouse over" color. 我更喜欢使用UIManager,但是找不到任何可以让我选择“按钮滑过”颜色的属性。 Take a look at the picture attached please: 请看所附图片:

在此处输入图片说明

Seems like i'm stuck with default Windows "light-blue" color for button mouse over (pointer is not visible in this screenshot). 好像我停留在默认的Windows“浅蓝色”颜色上,以将鼠标悬停在该按钮上(指针在此屏幕截图中不可见)。

How can i change that color? 我该如何更改颜色?

For me only option is some sort of UIManager global variable, i simply can't afford to go through all buttons in my app and override some custom button or add listeners for "mouse enter" and "mouse exit". 对我来说,唯一的选择是某种UIManager全局变量,我根本负担不起遍历应用程序中的所有按钮并覆盖一些自定义按钮或为“鼠标进入”和“鼠标退出”添加侦听器。

The best way to do it is to customize the LAF of your application, using this library TinyLAF . 最好的方法是使用此库TinyLAF定制应用程序的LAF。 Very easy to use, with nice control panel to help do some theming and using the created theme file on your project. 非常易于使用,具有出色的控制面板,可帮助您进行主题化以及在项目上使用创建的主题文件。

Here is a small tutorial on how to use it in case the doc is not too clear http://yourjavacode.blogspot.com.ng/2013/05/tinylaf-change-your-java-look-and-feel.html 这是一个关于如何在文档不太清晰的情况下使用它的小教程http://yourjavacode.blogspot.com.ng/2013/05/tinylaf-change-your-java-look-and-feel.html

I hope this helped out. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM