[英]Is it possible to change the background of a jspinner using the nimbus laf?
I'm fairly confident that I have done my research before coming to you for help, but it's possible I have overlooked something. 我相信我在向你寻求帮助之前已完成了我的研究,但我可能忽略了一些东西。
I'm writing a java UI using the Nimbus laf. 我正在使用Nimbus laf编写一个java UI。 I wish to change the background colour of a JSpinner on state-change, ie, when either the up or down button is pressed the background colour of the textfield within the jspinner changes colour to signify that the value has been altered.
我希望在状态改变时更改JSpinner的背景颜色,即,当按下向上或向下按钮时,jspinner中文本字段的背景颜色会改变颜色以表示该值已被更改。
I am aware this is possible using OTHER lookandfeels but not as easy with Nimbus, eg: ((JSpinner.NumberEditor)jSpinner1.getEditor()).getTextField().setBackground(color.yellow);
我知道这可以使用OTHER外观并使用Nimbus不那么容易,例如:
((JSpinner.NumberEditor)jSpinner1.getEditor()).getTextField().setBackground(color.yellow);
I have also looked into actually changing the colour theme of the UI manager, but I only want to change the colour when an action occurs, not just overall by default. 我还研究过实际更改UI管理器的颜色主题,但我只想在操作发生时更改颜色,而不仅仅是默认情况下的整体颜色。 here or here
在这里或这里
Is this at all possible and where do I start? 这有可能吗?我从哪里开始?
Failing this, I was hoping to just change a button's colour: jButton.setBackground(Color.yellow);
如果做不到这一点,我希望只是改变一个按钮的颜色:
jButton.setBackground(Color.yellow);
This is easy enough but since the default colour is a painted gradient, how do I change it back to that? 这很容易,但由于默认颜色是绘制的渐变,我该如何将其更改为?
Really hope someone out there knows or can help. 真的希望那里的人知道或可以提供帮助。
Much appreciated in advance! 非常感谢提前!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.