Java 在禁用的文本字段中设置字体颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3698859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 03:03:10  来源:igfitidea点击:

Java set Font Color in a disabled Text Field

javafontscolorstextfield

提问by Simiil

I have a disabled JTextField and due to readability problems i want to make the font black again. So that it looks like its not disabled, but i cant edit it. any suggestions?

我有一个禁用的 JTextField,由于可读性问题,我想让字体再次变黑。所以它看起来没有被禁用,但我无法编辑它。有什么建议?

回答by Faisal Feroz

You can use the setDisabledTextColor(Color c)method to set the desired color. For more information check: javadocs

您可以使用该setDisabledTextColor(Color c)方法设置所需的颜色。有关更多信息,请查看:javadocs

回答by JohnoBoy

Try using the method setDisabledTextColor (inherited from JTextComponent)

尝试使用 setDisabledTextColor 方法(继承自 JTextComponent)

回答by Fauziya

Please use setDisabledTextColor(Color.BLACK)to make your text color black.

请使用setDisabledTextColor(Color.BLACK)使您的文本颜色变黑。