获得面板颜色 [英] getting panel color

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

问题描述

我有一个程序,我有一个按钮可以将背景颜色更改为红色,另一个按钮可以设置默认的面板颜色。

I have a program where i have a button to change the background color to red and another button to set back the default panel color.

我如何取回面板的默认颜色??

How do i get back the default color for panel??

推荐答案

将默认颜色存储在构造函数中的变量中,或者在使用其他按钮更改颜色之前,即:

Store the default color to a variable in constructor or before changing the color with the other button, ie:

Color defaultColor = panel.getBackground();

在您的默认颜色按钮中:

And in your default color button:

panel.setBackground(defaultColor);

这篇关于获得面板颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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