JButton更改文本字段的文本颜色 [英] JButton changes text colour of textfield

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

问题描述

我正在尝试使用 JButton但是我不知何故 无法找到要执行此操作的特定功能.任何帮助,将不胜感激.谢谢. 如果我可以从可以搜索的地方获取资源,那也将是一个真正的帮助. 在Java中使用的不同功能.

I am trying to change the text colour in JTextfield using the JButton but somehow i am not able to find the specific function to do so. Any help would be appreciated. Thanks. Also it would be a real help if i could get the source from where i could search different functions with their use, used in java.

推荐答案

我正在尝试使用JButton更改JTextfield中的文本颜色,但是不知何故我找不到执行此操作的特定功能.

I am trying to change the text colour in JTextfield using the JButton but somehow i am not able to find the specific function to do so.

那是因为没有一个功能"可以改变JButton的文本颜色.您必须创建代码才能做到这一点.考虑使用:

That's because there is no one "function" that changes text color from a JButton. You have to create code to do it. Consider using:

  • ActionListener响应按钮按下
  • 在JTextField上
  • setForeground(Color newColor)调用以设置其前景/文本颜色.
  • 如何进行这些调用的细节都取决于您当前的代码,而我们尚未看到.
  • 查看Swing教程,以后再做一些研究,并在提出类似问题时展示您的尝试.否则,我们将不知道您可能做错了什么.请查看帮助部分以及如何提出好的问题,以了解如何改善该问题并增加获得体面答案的几率.
  • ActionListener to respond to button press
  • setForeground(Color newColor) call on the JTextField to set its foreground/text color.
  • The specifics on how to make these calls will all depend on your current code, something that we have not seen yet.
  • Check the Swing tutorials and do a little more research in the future and show your attempt when asking similar questions. Else we'll have no idea what you may be doing wrong. Please look at the help section as well as how to ask good questions to find out how you can improve this question and increase your odds of getting decent answers.

这篇关于JButton更改文本字段的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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