How to get JButton default background color?

2019-02-21 21:53发布

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 ?

7条回答
甜甜的少女心
2楼-- · 2019-02-21 22:38

Don't try to get background from Jframe or other elements to apply it on the button; if you already changed it do this:

ElementToStyle.setBackground(null);
查看更多
登录 后发表回答