JTextField together with HTML tags

醉酒当歌 提交于 2019-12-14 02:08:51

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/12231750/jtextfield-together-with-html-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!