更改按钮颜色后如何恢复按钮的原始外观和感觉颜色? [英] How to get back the original look and feel color of a button after changing its color?
本文介绍了更改按钮颜色后如何恢复按钮的原始外观和感觉颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我更改了按钮的颜色.现在,我想要它的原始外观.我想一次将颜色更改为我喜欢的颜色.之后,我希望按钮恢复其原始外观.
I changed the color of my button. Now I want its original look and feel back. I want to change the color once to a color that i like. After that, I want the button to get its original look back.
我该怎么做?
这是更改颜色的代码-
JButton but = JButton("Press now to up vote"); // :)
but.setBackground(Color.orange);
//code to remove this color and get the original look back ???
推荐答案
Color oldColor = myButton.getBackground();
myButton.setBackground(Color.RED);
// ... do stuff
myButton.setBackground(oldColor);
这篇关于更改按钮颜色后如何恢复按钮的原始外观和感觉颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文