How to get JButton default background color?

Frank picture Frank · Aug 31, 2009 · Viewed 38.5k times · Source

I use this myButton.setBackground(myColor) to change the JButton background color to my color, how to find it's original default background color so I can change it back? I know I can save its default background color before I change and use that, but I wonder if Java stores it somewhere so that maybe I can call something like: myButton.getClass.getDefaultBackground() to get it back ?

Answer

Shiburagi picture Shiburagi · May 9, 2014

btn.setBackground(new JButton().getBackground());

how about this... it will get the default color of button