我正在使用 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 标签。该文本示例只是一个示例。 可能是什么问题? 干杯
最佳答案
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>");
关于java - JTextField 和 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12231750/