Fra*_*ank 7 background default colors jbutton
我用这个myButton.setBackground(myColor)来改变JButton背景颜色到我的颜色,如何找到它的原始默认背景颜色,以便我可以改回来?我知道在更改和使用它之前我可以保存它的默认背景颜色,但是我想知道Java是否将它存储在某处,以便我可以调用类似的东西:myButton.getClass.getDefaultBackground()将它取回?
myButton.setBackground(null)
Run Code Online (Sandbox Code Playgroud)
将其更改回默认颜色.
这可能有帮助:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/SystemColor.html
Toolkit.getDesktopProperty(java.lang.String)
Toolkit.getDesktopProperty("control");
// control - The color rendered for the background of control panels and control objects, such as pushbuttons.
Run Code Online (Sandbox Code Playgroud)