Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I read a HTML String into a JEditorPane/JTextPane?

Pretty self explanatory, I have a string that is HTML, how do i draw this onto a JEditorPane/JTextPane?

like image 411
Primm Avatar asked Jul 20 '12 19:07

Primm


1 Answers

Do you mean something like this?

JFrame frame=new JFrame();
JEditorPane pane=new JEditorPane();
pane.setContentType("text/html");
String data="<table border=\"1\"><tr><td>cell1</td><td>cell2</td></tr></table>";
pane.setText(data);

frame.add(pane);
frame.setSize(200,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);
like image 100
Pshemo Avatar answered Nov 02 '22 23:11

Pshemo