我是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标签。这段文本只是一个例子。可能的问题是什么?谢谢。
我是Java 7的开发者。我正在尝试使用HTML标签格式化文本。我将文本传递到
JTextField text = new JTextField();
text.setText("<html><body><p>The program performs encryption operations on the following ciphers: </p></body></html>");
JTextField
不支持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>");
JTextField
吗?如果你只是想显示一些文本,那么JLabel
更适合。 - Jeffrey