The JEditorPane is responsible for showing of the html content.
It allows us to see the html content from a specific website or even from a html file on local computer.
If you want to show the contents from some URL instead from the offline html contents then you may do the following:
URL u=new URL("http://www.mysite.com");
JEditorPane ed2=new JEditorPane(u);
Reference link
HtmlContent.javaimport javax.swing.JEditorPane;
import javax.swing.JFrame;
public class HtmlContent extends JFrame {
public static void main(String args[]) {
new HtmlContent().start();
}
void start() {
try {
String html;
html="<html><head><title>Simple Page</title></head>";
html+="<body bgcolor='#f0f0ff'><hr/><font size=50>This is Html content</font><hr/>";
html+="</body></html>";
JEditorPane ed1=new JEditorPane("text/html",html);
add(ed1);
setVisible(true);
setSize(400,200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
catch(Exception e) {
System.err.println("Some problem has occured"+e.getMessage());
}
}
}
Maintained by John Loomis, updated Sat Apr 18 10:55:06 2020