如何获得的JButton默认背景色? [英] How to get JButton default background color?

查看:687
本文介绍了如何获得的JButton默认背景色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆