Example usage for javax.swing.event HyperlinkEvent getEventType

List of usage examples for javax.swing.event HyperlinkEvent getEventType

Introduction

In this page you can find the example usage for javax.swing.event HyperlinkEvent getEventType.

Prototype

public EventType getEventType() 

Source Link

Document

Gets the type of event.

Usage

From source file:org.nuclos.client.main.MainController.java

public void cmdShowAboutDialog() {
    try {// w  ww . j a va 2s. c  om
        final MainFrameTab internalFrame = newMainFrameTab(null, "Info");
        String html = IOUtils.readFromTextStream(
                getClass().getClassLoader().getResourceAsStream("org/nuclos/client/help/about/about.html"),
                null);

        Pair<String, String> clientLogFile = StartUp.getLogFile();
        String logDir = "";
        String logFilename = clientLogFile.x;
        String logDatePattern = clientLogFile.y;
        try {
            // try to extract dir and filename...
            logDir = clientLogFile.x.substring(0, clientLogFile.x.lastIndexOf("/"));
            logFilename = clientLogFile.x.substring(clientLogFile.x.lastIndexOf("/") + 1)
                    + logDatePattern.replace("'", "");
        } catch (Exception ex) {
            // do nothing
        }

        HtmlPanel htmlPanel = new HtmlPanel(
                String.format(html, ApplicationProperties.getInstance().getCurrentVersion(), // %1$s
                        getUserName(), // %2$s
                        getNuclosServerName(), // %3$s
                        System.getProperty("java.version"), // %4$s
                        logDir, // %5$s
                        logFilename // %6$s
                ));
        htmlPanel.btnClose.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ev) {
                internalFrame.dispose();
            }
        });
        htmlPanel.addHyperlinkListener(new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType() == EventType.ACTIVATED) {
                    try {
                        Desktop.getDesktop().browse(e.getURL().toURI());
                    } catch (IOException e1) {
                        LOG.warn("cmdShowAboutDialog " + e1 + ": " + e1, e1);
                    } catch (URISyntaxException e1) {
                        LOG.warn("cmdShowAboutDialog " + e1 + ": " + e1, e1);
                    }
                }
            }
        });
        internalFrame.setLayeredComponent(htmlPanel);
        Main.getInstance().getMainFrame().getHomePane().add(internalFrame);
        internalFrame.setVisible(true);
    } catch (Exception e) {
        Errors.getInstance().showExceptionDialog(Main.getInstance().getMainFrame(), getSpringLocaleDelegate()
                .getMessage("MainController.26", "Die Infos k\u00f6nnen nicht angezeigt werden."), e);
    }
}

From source file:org.openpythia.aboutdialog.AboutController.java

public AboutController(JFrame owner) {
    view = new AboutView(owner);
    view.getEditorPaneAbout().setContentType("text/html");

    String aboutText = "";

    try {/*from  www. j a  v a 2 s  .c  o m*/
        InputStream inputStream = this.getClass().getResourceAsStream(ABOUT_HTML);
        aboutText = String.format(IOUtils.toString(inputStream), FileResourceUtility.getVersion());
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }

    view.getEditorPaneAbout().setText(aboutText);

    view.getEditorPaneAbout().addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    Desktop.getDesktop().browse(evt.getURL().toURI());
                } catch (Exception e) {
                    // If we can't open the URL we just ignore it (no error
                    // message)
                }
            }
        }
    });

    view.getEditorPaneAbout().setCaretPosition(0);

    view.getBtnOK().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            view.dispose();
        }
    });

    view.getRootPane().setDefaultButton(view.getBtnOK());
    view.getBtnOK().requestFocus();

    view.setSize(600, 400);
    view.setVisible(true);
}

From source file:org.openpythia.dbconnection.MissingJDBCDriverController.java

private void prepareTextArea() {
    view.getEditorPaneMissingJDBCDriver().setContentType("text/html");

    String missingJDBCdriverText = "";

    try {//  www. j a va2 s  .c o m
        InputStream inputStream = this.getClass().getResourceAsStream(MISSING_JDBCDRIVER_HTML);
        missingJDBCdriverText = IOUtils.toString(inputStream);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }

    view.getEditorPaneMissingJDBCDriver().setText(missingJDBCdriverText);

    view.getEditorPaneMissingJDBCDriver().addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    Desktop.getDesktop().browse(evt.getURL().toURI());
                } catch (Exception e) {
                    // If we can't open the URL - for what reason
                    // ever - we ignore it
                }
            }
        }
    });
}

From source file:org.panbox.desktop.common.gui.AddContactToShareWizard.java

private void shareConfigLinkEditorPaneHyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {// GEN-FIRST:event_shareConfigLinkEditorPaneHyperlinkUpdate
    if (HyperlinkEvent.EventType.ACTIVATED.equals(evt.getEventType())) {
        if (this.finishedAccessControlConfig = openShareConfigLink()) {
            changedStep();/*from  ww  w  .  ja v a  2  s.com*/
        }
    }
}

From source file:org.yccheok.jstock.gui.Utils.java

public static void launchWebBrowser(javax.swing.event.HyperlinkEvent evt) {
    if (HyperlinkEvent.EventType.ACTIVATED.equals(evt.getEventType())) {
        URL url = evt.getURL();/*from w w  w.j  a v  a 2 s. c o  m*/
        if (Desktop.isDesktopSupported()) {
            final Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.BROWSE)) {
                if (url == null) {
                    // www.yahoo.com considered an invalid URL. Hence, evt.getURL() returns null.
                    String string = "http://" + evt.getDescription();
                    try {
                        url = new URL(string);
                    } catch (MalformedURLException ex) {
                        return;
                    }
                }
                try {
                    desktop.browse(url.toURI());
                } catch (URISyntaxException ex) {
                } catch (IOException ex) {
                }
            }
        }
    }
}

From source file:pl.kotcrab.arget.gui.MainWindow.java

private void createAndShowGUI() {
    setTitle(App.APP_NAME);//from   www.jav  a2 s. c om
    setBounds(100, 100, 800, 700);
    setMinimumSize(new Dimension(500, 250));
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setIconImage(App.loadImage("/data/icon/icon.png"));

    sessionWindowManager = new SessionWindowManager(this);

    if (profile.mainWindowBounds != null
            && GraphicsUtils.isRectangleDisplayableOnScreen(profile.mainWindowBounds))
        setBounds(profile.mainWindowBounds);

    createMenuBars();

    contactsPanel = new ContactsPanel(profile, this);

    statusPane = new JTextPane();
    statusPane.setBorder(new EmptyBorder(1, 3, 2, 0));
    statusPane.setContentType("text/html");
    statusPane.setBackground(null);
    statusPane.setHighlighter(null);
    statusPane.setEditable(false);
    statusPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    statusPane.setFont(new Font("Tahoma", Font.PLAIN, 13));

    statusPane.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
                String desc = e.getDescription();

                if (desc.startsWith("version-mismatch")) {
                    desc = desc.substring(desc.indexOf("://") + 3);
                    String[] versionInfo = desc.split("!");
                    new VersionMismatchDialog(MainWindow.instance, versionInfo[0],
                            Integer.valueOf(versionInfo[1]));
                }
            }
        }
    });

    JPanel bottomPanel = new JPanel(new BorderLayout(0, 0));

    getContentPane().add(bottomPanel, BorderLayout.SOUTH);

    scrollLockToggle = new WebToggleButton();
    scrollLockToggle.setToolTipText("Scroll lock");
    scrollLockToggle.setRolloverDecoratedOnly(true);
    scrollLockToggle.setDrawFocus(false);
    scrollLockToggle.setIcon(App.loadImageIcon("/data/scrolllock.png"));
    scrollLockToggle.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            postScrollLockUpdate();
        }
    });

    bottomPanel.add(statusPane);
    bottomPanel.add(scrollLockToggle, BorderLayout.EAST);

    splitPane = new JSplitPane();
    splitPane.setBorder(new BottomSplitPaneBorder());
    splitPane.setResizeWeight(0);
    splitPane.setContinuousLayout(true);
    splitPane.setOneTouchExpandable(true);
    getContentPane().add(splitPane, BorderLayout.CENTER);

    homePanel = new HomePanel(profile.fileName);
    logPanel = new LoggerPanel();

    errorStatusPanel = new ErrorStatusPanel();

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(contactsPanel, BorderLayout.CENTER);
    leftPanel.add(errorStatusPanel, BorderLayout.SOUTH);

    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(null);
    setCenterScreenTo(homePanel);

    addWindowFocusListener(new WindowAdapter() {
        @Override
        public void windowGainedFocus(WindowEvent e) {
            instance.validate();
            instance.revalidate();
            instance.repaint();

            getCenterScreen().onShow();
        }

        @Override
        public void windowLostFocus(WindowEvent e) {
            getCenterScreen().onHide();
        }

    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            ExitCleaner.forceExit();
        }
    });

    setVisible(true);
}

From source file:pl.kotcrab.arget.gui.session.msg.TextMessage.java

public TextMessage(MsgType type, String text, boolean markAsRead) {
    super(type);//from   w  w  w .j  av  a2s . co  m

    textPane = new JTextPane();
    textPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    textPane.setEditorKit(new WrapHTMLEditorKit());
    textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    textPane.setEditable(false);
    textPane.setBackground(null);
    textPane.setBorder(new EmptyBorder(3, 3, 0, 0));
    textPane.setFont(textFont);

    textPane.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent hle) {
            if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {

                if (DesktopUtils.openWebsite(hle.getURL()) == false)
                    JOptionPane.showMessageDialog(null, "Invalid URL: " + hle.getURL(), "Error",
                            JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    setText(text);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(textPane);

    DateFormat dateFormat = new SimpleDateFormat("[HH:mm] ");
    Date date = new Date();

    String textToShow = dateFormat.format(date);

    if (markAsRead == false)
        textToShow += "*";

    timeLabel = new JLabel(textToShow);
    timeLabel.setBorder(new EmptyBorder(0, 3, 3, 0));
    timeLabel.setForeground(Color.GRAY);
    timeLabel.setFont(smallTextFont);
    add(timeLabel);
}

From source file:tvbrowser.ui.settings.channel.ChannelGroupInfoDialog.java

/**
 * Create the GUI/* w w w.  j  av a  2  s.com*/
 */
private void initGui() {
    UiUtilities.registerForClosing(this);
    JPanel panel = (JPanel) getContentPane();
    panel.setBorder(Borders.DLU4_BORDER);
    panel.setLayout(new FormLayout("fill:default:grow, default", "fill:default:grow, 3dlu, default"));

    CellConstraints cc = new CellConstraints();

    final JEditorPane infoPanel = new JEditorPane();

    infoPanel.setEditorKit(new ExtendedHTMLEditorKit());

    ExtendedHTMLDocument doc = (ExtendedHTMLDocument) infoPanel.getDocument();

    infoPanel.setEditable(false);
    infoPanel.setText(generateHtml(doc));

    infoPanel.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                URL url = evt.getURL();
                if (url != null) {
                    Launch.openURL(url.toString());
                }
            }
        }
    });

    final JScrollPane scrollPane = new JScrollPane(infoPanel);
    panel.add(scrollPane, cc.xyw(1, 1, 2));

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));

    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            infoPanel.scrollRectToVisible(new Rectangle(0, 0));
        }
    });

    panel.add(ok, cc.xy(2, 3));

    setSize(500, 350);
}

From source file:tvbrowser.ui.settings.PluginInfoDialog.java

/**
 * Create the GUI/*from  w w  w  .  ja v a  2 s.co  m*/
 */
private void initGui() {

    JPanel panel = (JPanel) getContentPane();
    panel.setBorder(Borders.DLU4_BORDER);
    panel.setLayout(new FormLayout("fill:default:grow, default", "fill:default:grow, 3dlu, default"));

    CellConstraints cc = new CellConstraints();

    JEditorPane infoPanel = new JEditorPane();

    infoPanel.setEditorKit(new ExtendedHTMLEditorKit());

    ExtendedHTMLDocument doc = (ExtendedHTMLDocument) infoPanel.getDocument();

    infoPanel.setEditable(false);
    infoPanel.setText(generateHtml(doc));

    infoPanel.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                URL url = evt.getURL();
                if (url != null) {
                    Launch.openURL(url.toString());
                }
            }
        }
    });

    panel.add(new JScrollPane(infoPanel), cc.xyw(1, 1, 2));

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));

    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            close();
        }
    });

    panel.add(ok, cc.xy(2, 3));

    Settings.layoutWindow("pluginInfoDialog", this, new Dimension(700, 500));

    UiUtilities.registerForClosing(this);
}

From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.GiftCloudDialogs.java

public void showMessage(final String message) throws HeadlessException {

    final JPanel messagePanel = new JPanel(new GridBagLayout());
    final JEditorPane textField = new JEditorPane();
    textField.setContentType("text/html");
    textField.setText(message);/*from w w  w.j  a  v  a2s  .  c  om*/
    textField.setEditable(false);
    textField.setBackground(null);
    textField.setBorder(null);
    textField.setEditable(false);
    textField.setForeground(UIManager.getColor("Label.foreground"));
    textField.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    textField.setFont(UIManager.getFont("Label.font"));
    textField.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(e.getURL().toURI());
                    } catch (IOException e1) {
                        // Ignore failure to launch URL
                    } catch (URISyntaxException e1) {
                        // Ignore failure to launch URL
                    }
                }
            }
        }
    });

    messagePanel.add(textField);
    textField.setAlignmentX(SwingConstants.CENTER);

    JOptionPane.showMessageDialog(mainFrame.getContainer(), messagePanel, applicationName,
            JOptionPane.INFORMATION_MESSAGE, icon);
}