如何在java中改变一个禁用的JButton的外观 [英] How to change the look of a disabled JButton in java

查看:142
本文介绍了如何在java中改变一个禁用的JButton的外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作游戏,当我用 setEnabled(false); 禁用按钮时,按钮变成灰色,与游戏中的其他颜色冲突。

I am making a game and when I disable a button with setEnabled(false); the buttons turns grey which clashes with the other colors in the game. Is their a way to change the color of the button when it is disabled?

推荐答案

您可以在按钮上添加HTML代码

You can add HTML coding to your button which gives a large range of flexibility, even to disabled buttons.

Example: button.setText("<html><font color = red>3</font></html>");

这篇关于如何在java中改变一个禁用的JButton的外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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