简体   繁体   English

按下按钮时滑动JButton背景和前景色

[英]JButton background and foreground color swipe when button pressed

Could any one help to implement below thing? 有人可以帮助实现以下内容吗?

I have custom button which i have overloaded the paintComponent and plainText method to give my own look. 我有自定义按钮,我已经重载了paintComponent和plainText方法以给出自己的外观。 the main focus of overridden is to give my own style for buttons. 覆盖的主要重点是为按钮提供自己的样式。

so here the requirement is originally button background is white and foreground is black and when user press the button the color should revert like background as black and foreground as white. 所以这里的要求是最初按钮的背景是白色,前景是黑色,当用户按下按钮时,颜色应该像黑色一样恢复为背景,而白色则恢复为前景。

how can i achieve this? 我怎样才能做到这一点?

Instead of subclassing Swing components to modify how they «look and feel», you can provide your own UI implementation and attach it to a normal component instance. 您可以提供自己的UI实施并将其附加到普通的组件实例,而不必将Swing组件子类化以修改它们的“外观”。

Look at following methods: 查看以下方法:

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

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