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 l-a-f. 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.
I am aware this is possible using OTHER lookandfeels but not as easy with Nimbus, eg:
((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. 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);
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!
Yes, it is possible. See this example (i.e. SpinnerDemo4) from The Java Tutorials for more detail. And yes, I did set the LaF to Nimbus when testing the code therein.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With