JTextField与HTML标记一起使用

时间:2012-09-01 21:56:37

标签: java html swing jtextfield

我正在使用Java 7.我正在尝试使用HTML标记格式化文本。我将文字传入

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

但程序也打印HTML标签。那个文本样本只是一个例子。 可能是什么问题? 干杯

1 个答案:

答案 0 :(得分:8)

JTextField not support HTML。您可以改为使用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>");
相关问题