How do I change the color of a JButton if I am using JGoodies WindowsLookAndFeel
? After changing the color the button should still have some visual indication when it is clicked; the color gradient and click animation do not have to be the same as in JGoodies.
Using setBackground()
and setForeground()
only changes the color of the button outline and the button text:
import com.jgoodies.looks.windows.WindowsLookAndFeel;
...
public class Test {
public static void main(String[] args) throws UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
JFrame frame = new JFrame();
frame.setSize(50, 100);
JButton button = new JButton("Button");
button.setBackground(Color.GREEN);
button.setForeground(Color.RED);
button.setOpaque(true);
frame.add(button);
frame.setVisible(true);
}
}
I would like to set the color for the whole area of the button not just the outline. (This happens if the WindowsLookAndFeel
is not used.)
I have also tried changing the colors in com.jgoodies.looks.windows.WindowsBorders#getButtonBorder()
but this does not seem to have any effect.