简体   繁体   English

JTextField与HTML标记一起使用

[英]JTextField together with HTML tags

I am working on Java 7. I am trying to format text by using HTML tags. 我正在使用Java 7.我正在尝试使用HTML标签格式化文本。 I pass in text into 我把文字传入

JTextField text = new JTextField();
text.setText("<html><body><p>The program performs encryption operations on the following ciphers: </p></body></html>");

But the program prints the HTML tags too. 但程序也打印HTML标签。 That sample of text is only an example. 那个文本样本只是一个例子。 What might be the problem? 可能是什么问题? Cheers 干杯

JTextField does not support HTML . JTextField支持HTML You could use JTextPane instead: 你可以改用JTextPane

JTextPane text = new JTextPane();
text.setContentType("text/html");
text.setText("<html><body><p>The program performs encryption operations on the following ciphers: </p></body></html>");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM