简体   繁体   中英

JTextField together with HTML tags

I am working on Java 7. I am trying to format text by using HTML tags. 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. That sample of text is only an example. What might be the problem? Cheers

JTextField does not support HTML . You could use JTextPane instead:

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>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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