I have a Java application which uses the native LAF like so:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
This is working great, however, I am trying to make a button have a red background, but ends up like this:
As you can see, I'm setting background and foreground on the button, but what results is not visually pleasing. Is there a way to have the button draw a red background without subclassing JButton?
You must understand that under Swing's Look & Feel structure, it's the JButton's UI delegate that does its drawing, not the JButton itself, and so setBackground(...)
will not work well in this situation. You'll probably be better off adding an icon to the button instead.
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