use of javax.swing.event.HyperlinkListener in project airavata by apache.
the class AboutWindow method init.
@SuppressWarnings("serial")
private void init() {
JPanel buttonPanel = new JPanel();
JButton okButton = new JButton("OK");
okButton.setDefaultCapable(true);
okButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
hide();
}
});
buttonPanel.add(okButton);
String styles = "<style type=\"text/css\">" + "body {" + "font-family:Arial, Helvetica, sans-serif" + "}" + ".centeredImage" + "{" + " text-align:center;" + " display:block;" + "}" + "</style>";
buttonPanel.setBorder(BorderFactory.createEtchedBorder());
// "<img src=\""+SwingUtil.getImageURL("airavata-2.png").toString()+"\" class=\".centeredImage\" /><br>";
String imgLogoTag = "";
String imgHeadingTag = "<div style=\"width:100%;margin-right:10px;margin-left:10px;margin-top:5px;\" ><img src=\"" + SwingUtil.getImageURL("airavata-title-text.png").toString() + "\" class=\".centeredImage\" /></div><br>";
// "<h1>" + XBayaConstants.PROJECT_NAME + "</h1>";
String projectNameText = "";
String message = "<html>" + styles + "<body align=\"center\">" + "<div style=\"background-color:white;width:100%;margin-bottom:0px;\">" + projectNameText + imgHeadingTag + imgLogoTag + "</div><br><h2>" + XBayaConstants.APPLICATION_NAME + "</h2>" + "Version: " + XBayaVersion.VERSION + "<br>" + "<a href='" + XBayaConstants.WEB_URL.toString() + "'>" + XBayaConstants.WEB_URL.toString() + "</a>" + "<br> </body></html>";
JEditorPane editorPane = new JEditorPane(XmlConstants.CONTENT_TYPE_HTML, message);
editorPane.setEditable(false);
editorPane.setBorder(BorderFactory.createEtchedBorder());
editorPane.setBackground(buttonPanel.getBackground());
editorPane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent event) {
logger.debug("Event:" + event);
if (event.getEventType() == EventType.ACTIVATED) {
URL url = event.getURL();
try {
BrowserLauncher.openURL(url.toString());
} catch (Exception e) {
AboutWindow.this.engine.getGUI().getErrorWindow().error(AboutWindow.this.dialog.getDialog(), e.getMessage(), e);
}
}
}
});
this.dialog = new XBayaDialog(this.engine.getGUI(), XBayaConstants.PROJECT_NAME, editorPane, buttonPanel);
this.dialog.setDefaultButton(okButton);
// this.dialog.setCancelButton(okButton);
}
use of javax.swing.event.HyperlinkListener in project open-ecard by ecsec.
the class LogSettingsGroup method createSupportPanel.
private JComponent createSupportPanel() throws IOException {
HTMLEditorKit kit = new HTMLEditorKit();
HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
editorPane.setEditorKit(kit);
editorPane.setDocument(doc);
// editorPane.setMaximumSize(new Dimension(520, 400));
editorPane.setPreferredSize(new Dimension(520, 250));
URL url = I18n.getTranslation("richclient").translationForFile("debug", "html");
editorPane.setPage(url);
editorPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
openUrl(e);
}
});
return editorPane;
}
use of javax.swing.event.HyperlinkListener 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.event.HyperlinkListener in project mafscaling by vimsh.
the class ACompCalc method createUsageTab.
protected void createUsageTab() {
final Desktop desktop = Desktop.getDesktop();
JTextPane usageTextArea = new JTextPane();
usageTextArea.setMargin(new Insets(10, 10, 10, 10));
usageTextArea.setContentType("text/html");
usageTextArea.setText(usage());
usageTextArea.setEditable(false);
usageTextArea.setCaretPosition(0);
usageTextArea.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
try {
desktop.browse(new URI(e.getURL().toString()));
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
});
JScrollPane textScrollPane = new JScrollPane(usageTextArea);
textScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
textScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
add(textScrollPane, "<html><div style='text-align: center;'>U<br>s<br>a<br>g<br>e</div></html>");
}
Aggregations