use of javax.swing.text.html.HTMLEditorKit in project open-ecard by ecsec.
the class AboutDialog method createTabContent.
private JPanel createTabContent(String resourceName) {
HTMLEditorKit kit = new HTMLEditorKit();
// don't follow form link, use hyperlink handler instead
kit.setAutoFormSubmission(false);
HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
editorPane.setEditorKit(kit);
editorPane.setDocument(doc);
try {
URL url = LANG.translationForFile(resourceName, "html");
editorPane.setPage(url);
} catch (IOException ex) {
editorPane.setText("Page not found.");
}
editorPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
openUrl(e);
}
});
JScrollPane scrollPane = new JScrollPane(editorPane);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(scrollPane, BorderLayout.CENTER);
return panel;
}
use of javax.swing.text.html.HTMLEditorKit in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUIUtil method createDescriptionPane.
@NotNull
public static JTextPane createDescriptionPane() {
JTextPane result = new JTextPane();
result.addHyperlinkListener(new BrowserHyperlinkListener());
result.setContentType("text/html");
Font descriptionFont = UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
HTMLEditorKit editorKit = UIUtil.getHTMLEditorKit();
editorKit.getStyleSheet().addRule("body, p {" + "color:#" + ColorUtil.toHex(UIUtil.getLabelFontColor(UIUtil.FontColor.BRIGHTER)) + ";" + "font-family:" + descriptionFont.getFamily() + ";" + "font-size:" + descriptionFont.getSize() + "pt;}");
result.setHighlighter(null);
result.setEditorKit(editorKit);
return result;
}
Aggregations