Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 681
uml Avatar asked Dec 20 '22 16:12

uml


1 Answers

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>");
like image 189
Reimeus Avatar answered Dec 24 '22 00:12

Reimeus