I imported an HTML file to be displayed in a JEditorPane, and in the HTML code are links. In the application however, the links wont open anything when clicked. The HTML page is displaying great, but those links wont work with me. Do they become disabled in the JEditorPane? And how do I get them to open to the linked website when clicked?
static JPanel createResourcesPage() {
finalResourcesPage = new JPanel(new BorderLayout());
JEditorPane editorpane = new JEditorPane();
File file = new File("src/resourcesPageHTML.html");
try {
editorpane.setPage(file.toURI().toURL());
}
catch (MalformedURLException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
editorpane.setEditable(false);
JScrollPane scroll = new JScrollPane(editorpane);
scroll.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setPreferredSize(new Dimension(500, 300));
finalResourcesPage.add(scroll);
finalResourcesPage.add(editorpane);
return finalResourcesPage;
}
EDIT: Forgot to include that the HTML file doesn't contain only links. It's just that there are links in the file.