如何获得的JButton默认背景色? [英] How to get JButton default background color?
问题描述
我用这个 myButton.setBackground(myColor)
到的JButton
背景颜色更改为我的颜色,如何找到它的原始默认背景颜色,所以我可以改回来?我知道我能救它的默认背景色之前我更改并使用,但我不知道的Java存储它的地方,这样也许我可以调用类似: myButton.getClass.getDefaultBackground()
来把它找回来?
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 ?
推荐答案
btn.setBackground(的新的JButton()的getBackground());
这个怎么样?
它会得到按钮的默认颜色
how about this... it will get the default color of button
这篇关于如何获得的JButton默认背景色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!