Search in sources :

Example 56 with HyperlinkListener

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>&nbsp</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);
}
Also used : JPanel(javax.swing.JPanel) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JEditorPane(javax.swing.JEditorPane) AbstractAction(javax.swing.AbstractAction) URL(java.net.URL)

Example 57 with HyperlinkListener

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;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) HTMLDocument(javax.swing.text.html.HTMLDocument) JEditorPane(javax.swing.JEditorPane) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) Dimension(java.awt.Dimension) URL(java.net.URL)

Example 58 with HyperlinkListener

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;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) HyperlinkEvent(javax.swing.event.HyperlinkEvent) BorderLayout(java.awt.BorderLayout) HyperlinkListener(javax.swing.event.HyperlinkListener) HTMLDocument(javax.swing.text.html.HTMLDocument) JEditorPane(javax.swing.JEditorPane) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) IOException(java.io.IOException) URL(java.net.URL)

Example 59 with HyperlinkListener

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>");
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextPane(javax.swing.JTextPane) Insets(java.awt.Insets) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Desktop(java.awt.Desktop) HyperlinkListener(javax.swing.event.HyperlinkListener) URI(java.net.URI)

Aggregations

HyperlinkListener (javax.swing.event.HyperlinkListener)59 HyperlinkEvent (javax.swing.event.HyperlinkEvent)57 JEditorPane (javax.swing.JEditorPane)15 URL (java.net.URL)11 JScrollPane (javax.swing.JScrollPane)9 JPanel (javax.swing.JPanel)8 JTextPane (javax.swing.JTextPane)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 Dimension (java.awt.Dimension)6 IOException (java.io.IOException)6 NotNull (org.jetbrains.annotations.NotNull)6 HyperlinkLabel (com.intellij.ui.HyperlinkLabel)5 URI (java.net.URI)5 HTMLDocument (javax.swing.text.html.HTMLDocument)5 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)5 Project (com.intellij.openapi.project.Project)4 BorderLayout (java.awt.BorderLayout)4 ActionEvent (java.awt.event.ActionEvent)4 AnAction (com.intellij.openapi.actionSystem.AnAction)3 MouseEvent (java.awt.event.MouseEvent)3