Search in sources :

Example 51 with HyperlinkListener

use of javax.swing.event.HyperlinkListener in project GenericKnimeNodes by genericworkflownodes.

the class ParameterDialog method createHeader.

private void createHeader() {
    // use JPanel to be able to create a border
    headerpanel = new JPanel();
    headerpanel.setLayout(new BorderLayout());
    TitledBorder b = new TitledBorder(new EtchedBorder(), "Please cite:");
    b.setTitleFont(MAND_FONT);
    headerpanel.setBorder(b);
    headerpanel.setPreferredSize(new Dimension(table.getWidth(), 50));
    // fill the Panel with a non-editable HTML TextPane
    header = new JTextPane();
    header.setContentType("text/html");
    header.setEditable(false);
    header.addHyperlinkListener(new HyperlinkListener() {

        // Open Desktop browser when clicking links (e.g. dois)
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(e.getURL().toURI());
                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } catch (URISyntaxException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            }
        }
    });
    headerpanel.add(new JScrollPane(header));
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextPane(javax.swing.JTextPane) EtchedBorder(javax.swing.border.EtchedBorder) HyperlinkEvent(javax.swing.event.HyperlinkEvent) BorderLayout(java.awt.BorderLayout) HyperlinkListener(javax.swing.event.HyperlinkListener) Dimension(java.awt.Dimension) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) TitledBorder(javax.swing.border.TitledBorder)

Example 52 with HyperlinkListener

use of javax.swing.event.HyperlinkListener in project org.alloytools.alloy by AlloyTools.

the class SimpleGUI method doHelp.

/**
 * This method displays the help html.
 */
private Runner doHelp() {
    if (wrap)
        return wrapMe();
    try {
        int w = OurUtil.getScreenWidth(), h = OurUtil.getScreenHeight();
        final JFrame frame = new JFrame();
        final JEditorPane html1 = new JEditorPane("text/html", "");
        final JEditorPane html2 = new JEditorPane("text/html", "");
        final HTMLDocument doc1 = (HTMLDocument) (html1.getDocument());
        doc1.setAsynchronousLoadPriority(-1);
        final HTMLDocument doc2 = (HTMLDocument) (html2.getDocument());
        doc2.setAsynchronousLoadPriority(-1);
        html1.setPage(this.getClass().getResource("/help/Nav.html"));
        html2.setPage(this.getClass().getResource("/help/index.html"));
        HyperlinkListener hl = new HyperlinkListener() {

            @Override
            public final void hyperlinkUpdate(HyperlinkEvent e) {
                try {
                    if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
                        return;
                    if (e.getURL().getPath().endsWith("quit.htm")) {
                        frame.dispose();
                        return;
                    }
                    HTMLDocument doc = (HTMLDocument) (html2.getDocument());
                    // So that we can
                    doc.setAsynchronousLoadPriority(-1);
                    // catch any
                    // exception
                    // that may
                    // occur
                    html2.setPage(e.getURL());
                    html2.requestFocusInWindow();
                } catch (Throwable ex) {
                }
            }
        };
        html1.setEditable(false);
        html1.setBorder(new EmptyBorder(3, 3, 3, 3));
        html1.addHyperlinkListener(hl);
        html2.setEditable(false);
        html2.setBorder(new EmptyBorder(3, 3, 3, 3));
        html2.addHyperlinkListener(hl);
        JScrollPane scroll1 = OurUtil.scrollpane(html1);
        JScrollPane scroll2 = OurUtil.scrollpane(html2);
        JSplitPane split = OurUtil.splitpane(JSplitPane.HORIZONTAL_SPLIT, scroll1, scroll2, 150);
        split.setResizeWeight(0d);
        frame.setTitle("Alloy Analyzer Online Guide");
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(split, BorderLayout.CENTER);
        frame.pack();
        frame.setSize(w - w / 10, h - h / 10);
        frame.setLocation(w / 20, h / 20);
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.setVisible(true);
        html2.requestFocusInWindow();
    } catch (Throwable ex) {
        return null;
    }
    return null;
}
Also used : JScrollPane(javax.swing.JScrollPane) HyperlinkEvent(javax.swing.event.HyperlinkEvent) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) HyperlinkListener(javax.swing.event.HyperlinkListener) HTMLDocument(javax.swing.text.html.HTMLDocument) JEditorPane(javax.swing.JEditorPane) EmptyBorder(javax.swing.border.EmptyBorder) JSplitPane(javax.swing.JSplitPane)

Example 53 with HyperlinkListener

use of javax.swing.event.HyperlinkListener in project vcell by virtualcell.

the class LoginPanel method getDtrpnUseThisLink.

private JEditorPane getDtrpnUseThisLink() {
    if (dtrpnUseThisLink == null) {
        dtrpnUseThisLink = new JEditorPane();
        dtrpnUseThisLink.setBorder(null);
        dtrpnUseThisLink.setBackground(getBackground());
        dtrpnUseThisLink.setFont(new Font("Arial", Font.BOLD, 14));
        dtrpnUseThisLink.setContentType("text/html");
        String s = "<html><body bgcolor=\"#" + Hex.toString(new byte[] { (byte) (getBackground().getRed() & 0xFF), (byte) (getBackground().getGreen() & 0xFF), (byte) (getBackground().getBlue() & 0xFF) }) + "\"><center><font size=5 face=Arial>Use <a href=\"" + BeanUtils.getDynamicClientProperties().getProperty(PropertyLoader.ACKNOWLEGE_PUB__WEB_URL) + "\">this link</a> for details on how to<br>acknowledge Virtual Cell in your<br>publication and how to share your<br>published research through<br>the VCell database.</font></center></body></html>";
        // System.out.println(s);
        dtrpnUseThisLink.setText(s);
        dtrpnUseThisLink.setEditable(false);
        dtrpnUseThisLink.addHyperlinkListener(new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    DialogUtils.browserLauncher(LoginPanel.this, e.getURL().toString(), "Please visit " + BeanUtils.getDynamicClientProperties().getProperty(PropertyLoader.VCELL_URL) + " for Online Help");
                }
            }
        });
    }
    return dtrpnUseThisLink;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) JEditorPane(javax.swing.JEditorPane) Font(java.awt.Font)

Example 54 with HyperlinkListener

use of javax.swing.event.HyperlinkListener in project SKMCLauncher by SKCraft.

the class WebpagePanel method setDocument.

private void setDocument() {
    activated = true;
    JLayeredPane panel = new JLayeredPane();
    panel.setLayout(new WebpageLayoutManager());
    documentView = new JEditorPane();
    documentView.setEditable(false);
    documentView.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (e.getURL() != null) {
                    SwingHelper.openURL(e.getURL(), self);
                }
            }
        }
    });
    JScrollPane scrollPane = new JScrollPane(documentView);
    panel.add(scrollPane, new Integer(1));
    progressBar = new JProgressBar();
    progressBar.setIndeterminate(true);
    panel.add(progressBar, new Integer(2));
    add(panel, BorderLayout.CENTER);
}
Also used : JScrollPane(javax.swing.JScrollPane) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) JLayeredPane(javax.swing.JLayeredPane) JEditorPane(javax.swing.JEditorPane) JProgressBar(javax.swing.JProgressBar)

Example 55 with HyperlinkListener

use of javax.swing.event.HyperlinkListener in project triplea by triplea-game.

the class EngineVersionProperties method getOutOfDateComponent.

Component getOutOfDateComponent() {
    final JPanel panel = new JPanel(new BorderLayout());
    final JEditorPane intro = new JEditorPane("text/html", getOutOfDateMessage());
    intro.setEditable(false);
    intro.setOpaque(false);
    intro.setBorder(BorderFactory.createEmptyBorder());
    final HyperlinkListener hyperlinkListener = e -> {
        if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
            OpenFileUtility.openUrl(e.getDescription());
        }
    };
    intro.addHyperlinkListener(hyperlinkListener);
    panel.add(intro, BorderLayout.NORTH);
    final JEditorPane updates = new JEditorPane("text/html", getOutOfDateReleaseUpdates());
    updates.setEditable(false);
    updates.setOpaque(false);
    updates.setBorder(BorderFactory.createEmptyBorder());
    updates.addHyperlinkListener(hyperlinkListener);
    updates.setCaretPosition(0);
    final JScrollPane scroll = new JScrollPane(updates);
    // scroll.setBorder(BorderFactory.createEmptyBorder());
    panel.add(scroll, BorderLayout.CENTER);
    final Dimension maxDimension = panel.getPreferredSize();
    maxDimension.width = Math.min(maxDimension.width, 700);
    maxDimension.height = Math.min(maxDimension.height, 480);
    panel.setMaximumSize(maxDimension);
    panel.setPreferredSize(maxDimension);
    return panel;
}
Also used : HyperlinkListener(javax.swing.event.HyperlinkListener) Properties(java.util.Properties) HyperlinkEvent(javax.swing.event.HyperlinkEvent) URL(java.net.URL) IOException(java.io.IOException) BorderFactory(javax.swing.BorderFactory) Component(java.awt.Component) AtomicReference(java.util.concurrent.atomic.AtomicReference) TimeUnit(java.util.concurrent.TimeUnit) JScrollPane(javax.swing.JScrollPane) CountDownLatch(java.util.concurrent.CountDownLatch) ClientLogger(games.strategy.debug.ClientLogger) Dimension(java.awt.Dimension) OpenFileUtility(games.strategy.net.OpenFileUtility) UrlConstants(games.strategy.triplea.UrlConstants) JEditorPane(javax.swing.JEditorPane) BorderLayout(java.awt.BorderLayout) JPanel(javax.swing.JPanel) ClientContext(games.strategy.engine.ClientContext) Version(games.strategy.util.Version) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) HyperlinkListener(javax.swing.event.HyperlinkListener) JEditorPane(javax.swing.JEditorPane) Dimension(java.awt.Dimension)

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