如何在JTextField中删除文本? [英] how to strikethrough text in a JTextField?

查看:356
本文介绍了如何在JTextField中删除文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 JTextField 来显示文件名。如果文件无效,我想删除文本。怎么办呢?我试过html但没有运气。

I have JTextField to display a file name. I would like to strikethrough the text if the file is not valid. How can do this? I tried the html but no luck.

推荐答案

我很确定你不能在<$ c $中设置文本样式c> JTextField ,除了设置字体。我想你要么必须创建自己的子类来支持样式,要么创建一个 JTextPane 并将其设置为行为类似于 JTextField

I'm pretty sure you can't style text in a JTextField, beyond setting the font. I think you'll either have to create your own subclass which supports styling, or create a JTextPane and set it up to behave like a JTextField.

这里有一些很好的文档: http://download.oracle.com/javase/tutorial/uiswing/components/editorpane.html

There's some good documentation here: http://download.oracle.com/javase/tutorial/uiswing/components/editorpane.html

这篇关于如何在JTextField中删除文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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