Reputation: 146
I returned my JEditorPane in my program to a website, like google example, but it doesn't show correctly the page, well without its css style. uh, check my code :
JEditorPane editorPane = new JEditorPane() {
public boolean getScrollableTracksViewportWidth() {
return true;
}};
editorPane.setEditable(false);
HTMLEditorKit kit = new HTMLEditorKit();
Document doc = kit.createDefaultDocument();
editorPane.setDocument(doc);
editorPane.setEditorKit(kit);
try {
editorPane.setContentType("text/html");
editorPane.setPage("http://www.google.fr/");
}catch (IOException e) {
editorPane.setContentType("text/html");
editorPane.setText("<html>We can't load this page</html>"
+ e.getMessage() + " ");
}
editorPane.setBounds(295, 265, 491, 474);
editorPane.setBorder(new LineBorder(new Color(0, 0, 0)));
pan.add(editorPane);
I just want to show a website in a java component to show news and others information, can anyone help me please?
Upvotes: 1
Views: 275
Reputation: 324147
A JEditorPane only supports basic HTML.
For full support you can use the default browser of your system. Check out the section from the Swing tutorial on How to Integrate with the Desktop Class for a working example that uses the "BROWSE" functionality.
Upvotes: 1