我正在使用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标签。那个文本样本只是一个例子。 可能是什么问题? 干杯
答案 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>");