带有输入提示的 Java JTextField [英] Java JTextField with input hint
问题描述
我想向我的 javax.swing.JTextField
添加一个提示值.它应该看起来像 的 Firefox 渲染.这会在背景中创建一个带有文本bla"的编辑字段.如果文本框有焦点,则标题文本会消失,如果用户离开没有文本的编辑框,则会重新出现.
I would like to add a hint value to my javax.swing.JTextField
. It should look like Firefox rendering of <input type="text" title="bla">
. This creates an edit field with the text 'bla' in the background. If the textbox has focus the title-text disappears and just reappears if the user leaves the editbox without text.
是否有(免费的)摆动组件可以执行此类操作?
Is there a (free) swing component that does something like this?
推荐答案
看看这个:http://code.google.com/p/xswingx/
顺便说一句,自己实现它并不是很难.几个侦听器和自定义渲染器,瞧.
It is not very difficult to implement it by yourself, btw. A couple of listeners and custom renderer and voila.
这篇关于带有输入提示的 Java JTextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!