如何在JTextField中删除文本? [英] how to strikethrough text in a 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屋!