jTextField中的同构文本.如何? [英] Fantom-text in jTextField. How?
本文介绍了jTextField中的同构文本.如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们遇到了一些受欢迎的网站登录屏幕,其中在用户名文本框中输入了一个模糊的灰色用户名.我不知道可以在java swing中实现吗?
We come across some popular sites login screen, where a faint gray Username is written in username textbox. I wonder can be this implemented in java swings?
我有一些理论,可以通过mouseEvents实现.无法解决该怎么做.
I have theories, implementing by mouseEvents. Couldn't figure out how to to.
推荐答案
查看它允许您显示文本和/或图标,以提示使用文本字段.在文本字段中输入任何字符后,提示将被删除.
It allows you to display text and/or icon as a prompt for the usage of the text field. The prompt will be removed as soon as any characters are entered into the text field.
您还可以控制何时显示提示:
You can also control when the prompt is displayed:
-
ALWAYS
–是否显示文本字段是否具有焦点的提示. -
FOCUS_GAINED
–文本字段获得焦点时显示提示(丢失焦点时隐藏) -
FOCUS_LOST
–当文本字段失去焦点时显示提示(并在获得焦点时隐藏)
ALWAYS
– the prompt is displayed whether the text field has focus or not.FOCUS_GAINED
– the prompt is displayed when the text field gains focus (and is hidden when focus is lost)FOCUS_LOST
– the prompt is displayed when the text field loses focus (and is hidden when focus is gained)
这篇关于jTextField中的同构文本.如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文