带有输入提示的Java JTextField [英] Java JTextField with input hint

查看:757
本文介绍了带有输入提示的Java JTextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 javax.swing.JTextField 中添加一个提示值。它应该看起来像Firefox渲染< input type =texttitle =bla> 。这将在背景中创建一个带有文本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.

是否有(免费)swing组件执行此类操作?

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屋!

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