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:com.ln.gui.Main.java

@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        URL url = e.getURL();// ww w  .ja  va  2  s.co m
        String u = url.toString();
        try {
            java.awt.Desktop.getDesktop().browse(java.net.URI.create(u));
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }
}

From source file:com.mirth.connect.client.ui.NotificationDialog.java

private void initComponents() {
    setLayout(new MigLayout("insets 12", "[]", "[fill][]"));

    notificationPanel = new JPanel();
    notificationPanel.setLayout(new MigLayout("insets 0 0 0 0, fill", "[200!][]", "[25!]0[]"));
    notificationPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    archiveAll = new JLabel("Archive All");
    archiveAll.setForeground(java.awt.Color.blue);
    archiveAll.setText("<html><u>Archive All</u></html>");
    archiveAll.setToolTipText("Archive all notifications below.");
    archiveAll.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

    newNotificationsLabel = new JLabel();
    newNotificationsLabel.setFont(newNotificationsLabel.getFont().deriveFont(Font.BOLD));
    headerListPanel = new JPanel();
    headerListPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR);
    headerListPanel.setLayout(new MigLayout("insets 2, fill"));
    headerListPanel.setBorder(BorderFactory.createLineBorder(borderColor));

    list = new JList();
    list.setCellRenderer(new NotificationListCellRenderer());
    list.addListSelectionListener(new ListSelectionListener() {
        @Override// w  ww  .java 2s .  c  o  m
        public void valueChanged(ListSelectionEvent event) {
            if (!event.getValueIsAdjusting()) {
                currentNotification = (Notification) list.getSelectedValue();
                if (currentNotification != null) {
                    notificationNameTextField.setText(currentNotification.getName());
                    contentTextPane.setText(currentNotification.getContent());
                    archiveSelected();
                }
            }
        }
    });
    listScrollPane = new JScrollPane();
    listScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    listScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor));
    listScrollPane.setViewportView(list);
    listScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    archiveLabel = new JLabel();
    archiveLabel.setForeground(java.awt.Color.blue);
    archiveLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

    notificationNameTextField = new JTextField();
    notificationNameTextField.setFont(notificationNameTextField.getFont().deriveFont(Font.BOLD));
    notificationNameTextField.setEditable(false);
    notificationNameTextField.setFocusable(false);
    notificationNameTextField.setBorder(BorderFactory.createEmptyBorder());
    notificationNameTextField.setBackground(UIConstants.HIGHLIGHTER_COLOR);
    DefaultCaret nameCaret = (DefaultCaret) notificationNameTextField.getCaret();
    nameCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    headerContentPanel = new JPanel();
    headerContentPanel.setLayout(new MigLayout("insets 2, fill"));
    headerContentPanel.setBorder(BorderFactory.createLineBorder(borderColor));
    headerContentPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR);

    contentTextPane = new JTextPane();
    contentTextPane.setContentType("text/html");
    contentTextPane.setEditable(false);
    contentTextPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == EventType.ACTIVATED && Desktop.isDesktopSupported()) {
                try {
                    if (Desktop.isDesktopSupported()) {
                        Desktop.getDesktop().browse(evt.getURL().toURI());
                    } else {
                        BareBonesBrowserLaunch.openURL(evt.getURL().toString());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });
    DefaultCaret contentCaret = (DefaultCaret) contentTextPane.getCaret();
    contentCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    contentScrollPane = new JScrollPane();
    contentScrollPane.setViewportView(contentTextPane);
    contentScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor));

    archiveLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            int index = list.getSelectedIndex();
            if (currentNotification.isArchived()) {
                notificationModel.setArchived(false, index);
                unarchivedCount++;
            } else {
                notificationModel.setArchived(true, index);
                unarchivedCount--;
            }
            archiveSelected();
            updateUnarchivedCountLabel();
        }
    });

    archiveAll.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            for (int i = 0; i < notificationModel.getSize(); i++) {
                notificationModel.setArchived(true, i);
            }
            unarchivedCount = 0;
            archiveSelected();
            updateUnarchivedCountLabel();
        }
    });

    notificationCheckBox = new JCheckBox("Show new notifications on login");
    notificationCheckBox.setBackground(UIConstants.BACKGROUND_COLOR);

    if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) {
        checkForNotificationsSetting = true;
        if (showNotificationPopup == null || BooleanUtils.toBoolean(showNotificationPopup)) {
            notificationCheckBox.setSelected(true);
        } else {
            notificationCheckBox.setSelected(false);
        }
    } else {
        notificationCheckBox.setSelected(false);
    }

    notificationCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (notificationCheckBox.isSelected() && !checkForNotificationsSetting) {
                alertSettingsChange();
            }
        }
    });

    closeButton = new JButton("Close");
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doSave();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            doSave();
        }
    });
}

From source file:com.urswolfer.intellij.plugin.gerrit.rest.GerritUtil.java

public void showAddGitRepositoryNotification(final Project project) {
    NotificationBuilder notification = new NotificationBuilder(project,
            "Insufficient dependencies for Gerrit plugin",
            "Please configure a Git repository.<br/><a href='vcs'>Open Settings</a>")
                    .listener(new NotificationListener() {
                        @Override
                        public void hyperlinkUpdate(@NotNull Notification notification,
                                @NotNull HyperlinkEvent event) {
                            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                                if (event.getDescription().equals("vcs")) {
                                    ShowSettingsUtil.getInstance().showSettingsDialog(project,
                                            ActionsBundle.message("group.VcsGroup.text"));
                                }//from   w  w  w .ja  v  a  2s.c o  m
                            }
                        }
                    });
    notificationService.notifyWarning(notification);
}

From source file:de.ailis.xadrian.components.ComplexEditor.java

/**
 * @see HyperlinkListener#hyperlinkUpdate(HyperlinkEvent)
 *//* w  ww .j a  v  a2 s  . c o m*/
@Override
public void hyperlinkUpdate(final HyperlinkEvent e) {
    if (e.getEventType() != EventType.ACTIVATED)
        return;

    final URL url = e.getURL();
    final String protocol = url.getProtocol();

    if ("file".equals(protocol)) {
        final String action = url.getHost();
        if ("addFactory".equals(action)) {
            addFactory();
        } else if ("removeFactory".equals(action)) {
            removeFactory(Integer.parseInt(url.getPath().substring(1)));
        } else if ("disableFactory".equals(action)) {
            disableFactory(Integer.parseInt(url.getPath().substring(1)));
        } else if ("enableFactory".equals(action)) {
            enableFactory(Integer.parseInt(url.getPath().substring(1)));
        } else if ("acceptFactory".equals(action)) {
            acceptFactory(Integer.parseInt(url.getPath().substring(1)));
        } else if ("changeQuantity".equals(action)) {
            changeQuantity(Integer.parseInt(url.getPath().substring(1)));
        } else if ("increaseQuantity".equals(action)) {
            increaseQuantity(Integer.parseInt(url.getPath().substring(1)));
        } else if ("decreaseQuantity".equals(action)) {
            decreaseQuantity(Integer.parseInt(url.getPath().substring(1)));
        } else if ("changeYield".equals(action)) {
            changeYield(Integer.parseInt(url.getPath().substring(1)));
        } else if ("changeSuns".equals(action)) {
            changeSuns();
        } else if ("changeSector".equals(action)) {
            changeSector();
        } else if ("changePrice".equals(action)) {
            changePrices(this.complex.getGame().getWareFactory().getWare(url.getPath().substring(1)));
        } else if ("toggleShowingProductionStats".equals(action)) {
            toggleShowingProductionStats();
        } else if ("toggleShowingStorageCapacities".equals(action)) {
            toggleShowingStorageCapacities();
        } else if ("toggleShowingShoppingList".equals(action)) {
            toggleShowingShoppingList();
        } else if ("toggleShowingComplexSetup".equals(action)) {
            toggleShowingComplexSetup();
        } else if ("buildFactory".equals(action)) {
            buildFactory(url.getPath().substring(1));
        } else if ("destroyFactory".equals(action)) {
            destroyFactory(url.getPath().substring(1));
        } else if ("buildKit".equals(action)) {
            buildKit();
        } else if ("destroyKit".equals(action)) {
            destroyKit();
        }
    }
}

From source file:net.minelord.gui.panes.IRCPane.java

public void startClient(final String nick) {
    IRCLog = new ArrayList<String>();
    SwingUtilities.invokeLater(new Runnable() {
        @Override//from   w w  w  . j a  v a 2 s .  co  m
        public void run() {
            text = new JEditorPane("text/html", "<HTML>");
            text.setEditable(false);
            kit = new HTMLEditorKit();
            text.setEditorKit(kit);
            client.connect("irc.liberty-unleashed.co.uk", "#moomoohk", nick, instance);
            scroller = new JScrollPane(text);
            text.setEditable(false);
            connect();
            scroller.setBounds(20, 20, 810, 250);
            add(scroller);
            input = new JTextField();
            input.setBounds(20, 270, 810, 30);
            Color bgColor = Color.gray.darker().darker();
            UIDefaults defaults = new UIDefaults();
            defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
            text.putClientProperty("Nimbus.Overrides", defaults);
            text.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
            text.setBackground(bgColor);
            input.setBackground(Color.gray);
            input.setForeground(Color.gray.darker().darker().darker());
            input.setEnabled(false);
            text.addHyperlinkListener(new HyperlinkListener() {
                @Override
                public void hyperlinkUpdate(HyperlinkEvent event) {
                    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                        if (event.getDescription().charAt(0) == '#') {
                            String[] params = { event.getDescription() };
                            IRCCommand.getCommand("/join").execute(client, params);
                        } else
                            OSUtils.browse(event.getURL().toString());
                    }
                }
            });
            text.addFocusListener(new FocusListener() {

                @Override
                public void focusLost(FocusEvent paramFocusEvent) {
                }

                @Override
                public void focusGained(FocusEvent paramFocusEvent) {
                    input.requestFocus();
                }
            });
            scroller.setViewportView(text);
            add(input);
            input.addKeyListener(new KeyListener() {

                @Override
                public void keyTyped(KeyEvent arg0) {
                }

                @Override
                public void keyReleased(KeyEvent arg0) {
                    if (arg0.getKeyCode() == 10) {
                        if (input.getText().length() > 0) {
                            lastCommandSelector = lastCommands.size();
                            lastCommands.add(input.getText());
                        }
                        sendMessage(input.getText());
                        input.setText("");
                    }
                    if (arg0.getKeyCode() == 27)
                        input.setText("");
                    if (arg0.getKeyCode() == 17) {
                        int before = input.getText().length();
                        if (input.getText().charAt(0) == '/') {
                            input.setText(completeNick(input.getText()));
                            input.select(
                                    input.getText().length() - completeNick(input.getText()).length() + before,
                                    input.getText().length());
                        } else {
                            input.setText(completeCommand(input.getText()));
                            input.select(input.getText().length() - completeCommand(input.getText()).length()
                                    + before, input.getText().length());
                        }
                    }
                    if (arg0.getKeyCode() == 38)
                        if (lastCommandSelector > 0) {
                            lastCommandSelector--;
                            input.setText(lastCommands.get(lastCommandSelector));
                        }
                    if (arg0.getKeyCode() == 40)
                        if (lastCommandSelector < lastCommands.size()) {
                            lastCommandSelector++;
                            if (lastCommandSelector == lastCommands.size())
                                input.setText("");
                            if (lastCommandSelector < lastCommands.size())
                                input.setText(lastCommands.get(lastCommandSelector));
                            return;
                        }
                }

                @Override
                public void keyPressed(KeyEvent arg0) {
                }
            });
        }
    });
}

From source file:edu.ku.brc.specify.ui.AppBase.java

/**
 * Shows the About dialog.//from w  w  w. j a  v a  2s.co m
 */
public void doAbout() {
    AppContextMgr acm = AppContextMgr.getInstance();
    boolean hasContext = acm.hasContext();

    int baseNumRows = 9;
    String serverName = AppPreferences.getLocalPrefs().get("login.servers_selected", null);
    if (serverName != null) {
        baseNumRows++;
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder infoPB = new PanelBuilder(new FormLayout("p,6px,f:p:g",
            "p,4px,p,4px," + UIHelper.createDuplicateJGoodiesDef("p", "2px", baseNumRows)));

    JLabel iconLabel = new JLabel(IconManager.getIcon("SpecifyLargeIcon"), SwingConstants.CENTER); //$NON-NLS-1$
    PanelBuilder iconPB = new PanelBuilder(new FormLayout("p", "20px,t:p,f:p:g"));
    iconPB.add(iconLabel, cc.xy(1, 2));

    if (hasContext) {
        DBTableIdMgr tableMgr = DBTableIdMgr.getInstance();
        boolean hasReged = !RegisterSpecify.isAnonymous() && RegisterSpecify.hasInstitutionRegistered();

        int y = 1;
        infoPB.addSeparator(getResourceString("Specify.SYS_INFO"), cc.xyw(1, y, 3));
        y += 2;

        JLabel lbl = UIHelper.createLabel(databaseName);
        infoPB.add(UIHelper.createI18NFormLabel("Specify.DB"), cc.xy(1, y));
        infoPB.add(lbl, cc.xy(3, y));
        y += 2;
        lbl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    openLocalPrefs();
                }
            }
        });

        infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Institution.getClassTableId())),
                cc.xy(1, y));
        infoPB.add(lbl = UIHelper.createLabel(acm.getClassObject(Institution.class).getName()), cc.xy(3, y));
        y += 2;
        lbl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    openRemotePrefs();
                }
            }
        });
        infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Division.getClassTableId())), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(acm.getClassObject(Division.class).getName()), cc.xy(3, y));
        y += 2;

        infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Discipline.getClassTableId())), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(acm.getClassObject(Discipline.class).getName()), cc.xy(3, y));
        y += 2;

        infoPB.add(UIHelper.createFormLabel(tableMgr.getTitleForId(Collection.getClassTableId())), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(acm.getClassObject(Collection.class).getCollectionName()), cc.xy(3, y));
        y += 2;

        infoPB.add(UIHelper.createI18NFormLabel("Specify.BLD"), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(appBuildVersion), cc.xy(3, y));
        y += 2;

        infoPB.add(UIHelper.createI18NFormLabel("Specify.REG"), cc.xy(1, y));
        infoPB.add(UIHelper.createI18NLabel(hasReged ? "Specify.HASREG" : "Specify.NOTREG"), cc.xy(3, y));
        y += 2;

        String isaNumber = RegisterSpecify.getISANumber();
        infoPB.add(UIHelper.createI18NFormLabel("Specify.ISANUM"), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(StringUtils.isNotEmpty(isaNumber) ? isaNumber : ""), cc.xy(3, y));
        y += 2;

        if (serverName != null) {
            infoPB.add(UIHelper.createI18NFormLabel("Specify.SERVER"), cc.xy(1, y));
            infoPB.add(UIHelper.createLabel(StringUtils.isNotEmpty(serverName) ? serverName : ""), cc.xy(3, y));
            y += 2;
        }

        if (StringUtils.contains(DBConnection.getInstance().getConnectionStr(), "mysql")) {
            Vector<Object[]> list = BasicSQLUtils.query("select version() as ve");
            if (list != null && list.size() > 0) {
                infoPB.add(UIHelper.createFormLabel("MySQL Version"), cc.xy(1, y));
                infoPB.add(UIHelper.createLabel(list.get(0)[0].toString()), cc.xy(3, y));
                y += 2;
            }
        }

        infoPB.add(UIHelper.createFormLabel("Java Version"), cc.xy(1, y));
        infoPB.add(UIHelper.createLabel(System.getProperty("java.version")), cc.xy(3, y));
        y += 2;
    }

    String txt = getAboutText(appName, appVersion);
    JLabel txtLbl = createLabel(txt);
    txtLbl.setFont(UIRegistry.getDefaultFont());

    final JEditorPane txtPane = new JEditorPane("text/html", txt);
    txtPane.setEditable(false);
    txtPane.setBackground(new JPanel().getBackground());

    PanelBuilder pb = new PanelBuilder(new FormLayout("p,20px,f:min(400px;p):g,10px,8px,10px,p:g", "f:p:g"));

    pb.add(iconPB.getPanel(), cc.xy(1, 1));
    pb.add(txtPane, cc.xy(3, 1));
    Color bg = getBackground();

    if (hasContext) {
        pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xy(5, 1));
        pb.add(infoPB.getPanel(), cc.xy(7, 1));
    }

    pb.setDefaultDialogBorder();

    String title = getResourceString("Specify.ABOUT");//$NON-NLS-1$
    CustomDialog aboutDlg = new CustomDialog(topFrame, title + " " + appName, true, CustomDialog.OK_BTN, //$NON-NLS-1$
            pb.getPanel());
    String okLabel = getResourceString("Specify.CLOSE");//$NON-NLS-1$
    aboutDlg.setOkLabel(okLabel);

    aboutDlg.createUI();
    aboutDlg.pack();

    // for some strange reason I can't get the dialog to size itself correctly
    Dimension size = aboutDlg.getSize();
    size.height += 120;
    aboutDlg.setSize(size);

    txtPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent event) {
            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    AttachmentUtils.openURI(event.getURL().toURI());

                } catch (Exception e) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                }
            }
        }
    });

    UIHelper.centerAndShow(aboutDlg);
}

From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java

private void initComponents() {
    JPanel mainPanel = new JPanel(new GridBagLayout());

    // Base font for all components on the form
    Font baseFont = new JLabel("base font").getFont().deriveFont(11f);

    // Title panel
    JPanel titlePanel = new JPanel(new FlowLayout(LEFT));
    titlePanel.setBackground(WHITE);// ww  w.j a va  2s  .c  o m
    // titlePanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    JLabel titleLabel = new JLabel(WELCOME);
    titleLabel.setFont(baseFont.deriveFont(BOLD, 13.5f));
    // titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
    JLabel titleIcon = new JLabel(tavernaCogs32x32Icon);
    // titleIcon.setBorder(new EmptyBorder(10, 10, 10, 10));
    DialogTextArea titleMessage = new DialogTextArea(PLEASE_FILL_IN_THIS_REGISTRATION_FORM);
    titleMessage.setMargin(new Insets(0, 20, 0, 10));
    titleMessage.setFont(baseFont);
    titleMessage.setEditable(false);
    titleMessage.setFocusable(false);
    // titlePanel.setBorder( new EmptyBorder(10, 10, 0, 10));
    JPanel messagePanel = new JPanel(new BorderLayout());
    messagePanel.add(titleLabel, NORTH);
    messagePanel.add(titleMessage, CENTER);
    messagePanel.setBackground(WHITE);
    titlePanel.add(titleIcon);
    titlePanel.add(messagePanel);
    addDivider(titlePanel, BOTTOM, true);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    // gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(titlePanel, gbc);

    // Registration messages
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    // gbc.insets = new Insets(5, 0, 0, 10);
    DialogTextArea registrationMessage1 = new DialogTextArea(WHY_REGISTER);
    registrationMessage1.setMargin(new Insets(0, 10, 0, 0));
    registrationMessage1.setFont(baseFont);
    registrationMessage1.setEditable(false);
    registrationMessage1.setFocusable(false);
    registrationMessage1.setBackground(getBackground());

    DialogTextArea registrationMessage2 = new DialogTextArea(WE_DO);
    registrationMessage2.setMargin(new Insets(0, 10, 0, 10));
    registrationMessage2.setFont(baseFont);
    registrationMessage2.setEditable(false);
    registrationMessage2.setFocusable(false);
    registrationMessage2.setBackground(getBackground());
    JPanel registrationMessagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    registrationMessagePanel.add(registrationMessage1);
    registrationMessagePanel.add(registrationMessage2);
    addDivider(registrationMessagePanel, BOTTOM, true);
    mainPanel.add(registrationMessagePanel, gbc);

    // Mandatory label
    // JLabel mandatoryLabel = new JLabel("* Mandatory fields");
    // mandatoryLabel.setFont(baseFont);
    // gbc.weightx = 0.0;
    // gbc.weighty = 0.0;
    // gbc.gridx = 0;
    // gbc.gridy = 3;
    // gbc.fill = NONE;
    // gbc.anchor = GridBagConstraints.EAST;
    // gbc.gridwidth = 2;
    // gbc.insets = new Insets(0, 10, 0, 20);
    // mainPanel.add(mandatoryLabel, gbc);

    // First name
    JLabel firstNameLabel = new JLabel(FIRST_NAME);
    firstNameLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0, 10, 0, 10);
    mainPanel.add(firstNameLabel, gbc);

    firstNameTextField = new JTextField();
    firstNameTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        firstNameTextField.setText(previousRegistrationData.getFirstName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(firstNameTextField, gbc);

    // Last name
    JLabel lastNameLabel = new JLabel(LAST_NAME);
    lastNameLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0, 10, 0, 10);
    mainPanel.add(lastNameLabel, gbc);

    lastNameTextField = new JTextField();
    lastNameTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        lastNameTextField.setText(previousRegistrationData.getLastName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(lastNameTextField, gbc);

    // Email address
    JLabel emailLabel = new JLabel(EMAIL_ADDRESS);
    emailLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(emailLabel, gbc);

    emailTextField = new JTextField();
    emailTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        emailTextField.setText(previousRegistrationData.getEmailAddress());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(emailTextField, gbc);

    // Keep me informed
    keepMeInformedCheckBox = new JCheckBox(KEEP_ME_INFORMED);
    keepMeInformedCheckBox.setFont(baseFont);
    if (previousRegistrationData != null)
        keepMeInformedCheckBox.setSelected(previousRegistrationData.getKeepMeInformed());
    keepMeInformedCheckBox.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                keepMeInformedCheckBox.setSelected(!keepMeInformedCheckBox.isSelected());
            }
        }
    });
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(keepMeInformedCheckBox, gbc);

    // Institution name
    JLabel institutionLabel = new JLabel(INSTITUTION_COMPANY_NAME);
    institutionLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 8;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(institutionLabel, gbc);

    institutionOrCompanyTextField = new JTextField();
    institutionOrCompanyTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        institutionOrCompanyTextField.setText(previousRegistrationData.getInstitutionOrCompanyName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(institutionOrCompanyTextField, gbc);

    // Industry type
    JLabel industryLabel = new JLabel(" Industry type:");
    industryLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 9;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(industryLabel, gbc);

    industryTypeTextField = new JComboBox<>(industryTypes);
    industryTypeTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        industryTypeTextField.setSelectedItem(previousRegistrationData.getIndustry());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 9;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(industryTypeTextField, gbc);

    // Field of investigation
    JTextArea fieldLabel = new JTextArea(FIELD_OF_INVESTIGATION);
    fieldLabel.setFont(baseFont);
    fieldLabel.setEditable(false);
    fieldLabel.setFocusable(false);
    fieldLabel.setBackground(getBackground());
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 10;
    gbc.fill = NONE;
    gbc.anchor = LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(fieldLabel, gbc);

    fieldTextField = new JTextField();
    fieldTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        fieldTextField.setText(previousRegistrationData.getField());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 10;
    gbc.fill = HORIZONTAL;
    gbc.anchor = FIRST_LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(fieldTextField, gbc);

    // Purpose of using Taverna
    JTextArea purposeLabel = new JTextArea(WHY_YOU_INTEND_TO_USE_TAVERNA);
    purposeLabel.setFont(baseFont);
    purposeLabel.setEditable(false);
    purposeLabel.setFocusable(false);
    purposeLabel.setBackground(getBackground());
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 11;
    gbc.fill = NONE;
    gbc.anchor = LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(purposeLabel, gbc);

    purposeTextArea = new JTextArea(4, 30);
    purposeTextArea.setFont(baseFont);
    purposeTextArea.setLineWrap(true);
    purposeTextArea.setAutoscrolls(true);
    if (previousRegistrationData != null)
        purposeTextArea.setText(previousRegistrationData.getPurposeOfUsingTaverna());
    purposeTextArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_TAB) {
                if (evt.getModifiers() > 0)
                    purposeTextArea.transferFocusBackward();
                else
                    purposeTextArea.transferFocus();
                evt.consume();
            }
        }
    });
    JScrollPane purposeScrollPane = new JScrollPane(purposeTextArea);
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 11;
    gbc.fill = HORIZONTAL;
    gbc.anchor = FIRST_LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(purposeScrollPane, gbc);

    // Terms and conditions
    termsAndConditionsCheckBox = new JCheckBox(I_AGREE_TO_THE_TERMS_AND_CONDITIONS);
    termsAndConditionsCheckBox.setFont(baseFont);
    termsAndConditionsCheckBox.setBorder(null);
    termsAndConditionsCheckBox.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                termsAndConditionsCheckBox.setSelected(!termsAndConditionsCheckBox.isSelected());
            }
        }
    });
    // gbc.weightx = 0.0;
    // gbc.weighty = 0.0;
    // gbc.gridx = 0;
    // gbc.gridy = 12;
    // gbc.fill = NONE;
    // gbc.anchor = WEST;
    // gbc.gridwidth = 2;
    // gbc.insets = new Insets(10, 10, 0, 0);
    // mainPanel.add(termsAndConditionsCheckBox, gbc);

    // Terms and conditions link
    JEditorPane termsAndConditionsURL = new JEditorPane();
    termsAndConditionsURL.setEditable(false);
    termsAndConditionsURL.setBackground(getBackground());
    termsAndConditionsURL.setFocusable(false);
    HTMLEditorKit kit = new HTMLEditorKit();
    termsAndConditionsURL.setEditorKit(kit);
    StyleSheet styleSheet = kit.getStyleSheet();
    // styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}");
    // // base font looks bigger when rendered as HTML
    styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:9px;}");
    Document doc = kit.createDefaultDocument();
    termsAndConditionsURL.setDocument(doc);
    termsAndConditionsURL.setText("<html><body><a href=\"" + TERMS_AND_CONDITIONS_URL + "\">"
            + TERMS_AND_CONDITIONS_URL + "</a></body></html>");
    termsAndConditionsURL.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent he) {
            if (he.getEventType() == ACTIVATED)
                followHyperlinkToTandCs();
        }
    });
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 13;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 10, 0, 10);
    JPanel termsAndConditionsPanel = new JPanel(new FlowLayout(LEFT));
    termsAndConditionsPanel.add(termsAndConditionsCheckBox);
    termsAndConditionsPanel.add(termsAndConditionsURL);
    mainPanel.add(termsAndConditionsPanel, gbc);

    // Button panel
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JButton registerButton = new JButton("Register");
    registerButton.setFont(baseFont);
    registerButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                register();
            }
        }
    });
    registerButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            register();
        }
    });
    JButton doNotRegisterButton = new JButton("Do not ask me again");
    doNotRegisterButton.setFont(baseFont);
    doNotRegisterButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                doNotRegister();
            }
        }
    });
    doNotRegisterButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doNotRegister();
        }
    });
    JButton remindMeLaterButton = new JButton("Remind me later"); // in 2 weeks
    remindMeLaterButton.setFont(baseFont);
    remindMeLaterButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                remindMeLater();
            }
        }
    });
    remindMeLaterButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            remindMeLater();
        }
    });
    buttonPanel.add(registerButton);
    buttonPanel.add(remindMeLaterButton);
    buttonPanel.add(doNotRegisterButton);
    addDivider(buttonPanel, TOP, true);
    gbc.gridx = 0;
    gbc.gridy = 14;
    gbc.fill = HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(5, 10, 0, 10);
    gbc.gridwidth = 2;
    mainPanel.add(buttonPanel, gbc);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, CENTER);

    pack();
    setResizable(false);
    // Center the dialog on the screen (we do not have the parent)
    Dimension dimension = getToolkit().getScreenSize();
    Rectangle abounds = getBounds();
    setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2);
    setSize(getPreferredSize());
}

From source file:Main.Interface_Main.java

private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed

    // for copying style
    JLabel label = new JLabel();
    Font font = label.getFont();// w  w w  .j av a 2  s.c om

    // create some css from the label's font
    StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
    style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
    style.append("font-size:" + font.getSize() + "pt;");

    // html content
    JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
            + "This application was designed by <A HREF=http://www.friedcircuits.us>FriedCircuits</A> for the USB Tester." //
            + "<br><br><center>App Version: " + appVersion + "<br>FW Version: " + FW_VERSION
            + "</center><br><br>*Connect once to get FW version.</body></html>");

    // handle link events
    ep.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                java.awt.Desktop desktop = java.awt.Desktop.getDesktop();

                URI uri;
                try {
                    uri = new java.net.URI("www.friedcircuits.us");
                    if (desktop.isSupported(Desktop.Action.BROWSE)) {
                        try {
                            desktop.browse(uri);
                        } catch (IOException ex) {
                            Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                } catch (URISyntaxException ex) {
                    Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex);
                }

            } // roll your own link launcher or use Desktop if J6+
        }
    });
    Color bgColor = label.getBackground();
    UIDefaults defaults = new UIDefaults();
    defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
    ep.putClientProperty("Nimbus.Overrides", defaults);
    ep.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
    ep.setEditable(false);
    ep.setBackground(bgColor);

    // show
    ImageIcon myCustomIcon = new ImageIcon(getClass().getResource("/faviconbot2edit.png"));
    JOptionPane.showMessageDialog(plCurrent, ep, "About", JOptionPane.INFORMATION_MESSAGE, myCustomIcon);
}

From source file:com.farouk.projectapp.FirstGUI.java

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
    jPanel10.setVisible(true);/*from   w w  w .j a va  2  s  .  com*/
    StringBuilder temp = new StringBuilder();
    int row = jTable2.getSelectedRow();
    String name = (jTable2.getModel().getValueAt(row, 0).toString());
    for (YahooNews y : YahooNews.getRss(SQLConnect.getSymbolOfCompanyFromDB(name))) {
        temp.append(y.toString());
    }
    jEditorPane1.setContentType("text/html");
    jEditorPane1.setText(temp.toString());
    jEditorPane1.setCaretPosition(0);
    jEditorPane1.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
                System.out.println(e.getURL());
                Desktop desktop = Desktop.getDesktop();
                try {
                    desktop.browse(e.getURL().toURI());
                } catch (Exception ex) {
                    System.err.println("Problem in link click.\n" + ex);
                }
            }
        }
    });

    jEditorPane1.setEditable(false);

}

From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java

private void showUpdateResults(boolean updateAvailable) {
    String text = "";
    if (updateAvailable) {
        text = "<html><body>jMetrik Update Available. <br>"
                + "Go to  <a href=http://www.itemanalysis.com/jmetrik_download.php>http://www.itemanalysis.com/jmetrik-download.php</a><br>"
                + "and download the new version.<br>" + "</body></html>";
    } else {/* w  w w.  j  av a  2 s.c  om*/
        text = "<html><body>No Update Available. <br>"
                + "You have the most current version of jMetrik. <br></body></html>";
    }

    final JEditorPane p = new JEditorPane("text/html", text);
    p.setEditable(false);
    p.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                Desktop deskTop = Desktop.getDesktop();
                try {
                    URI uri = new URI("http://www.itemanalysis.com/jmetrik-download.php");
                    deskTop.browse(uri);
                } catch (URISyntaxException ex) {
                    logger.fatal(ex.getMessage(), ex);
                } catch (IOException ex) {
                    logger.fatal(ex.getMessage(), ex);
                }
            }
        }
    });
    JOptionPane.showMessageDialog(Jmetrik.this, p, "jMetrik Update Status", JOptionPane.INFORMATION_MESSAGE);
}