Example usage for java.beans PropertyChangeListener PropertyChangeListener

List of usage examples for java.beans PropertyChangeListener PropertyChangeListener

Introduction

In this page you can find the example usage for java.beans PropertyChangeListener PropertyChangeListener.

Prototype

PropertyChangeListener

Source Link

Usage

From source file:EditorPaneExample14.java

public EditorPaneExample14() {
    super("JEditorPane Example 14");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//from ww  w . j a  va 2s.c  o  m
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Modify the default style sheet
    InputStream is = EditorPaneExample14.class.getResourceAsStream("changedDefault.css");
    if (is != null) {
        try {
            addToStyleSheet(editorKit.getStyleSheet(), is);
        } catch (IOException e) {
            System.out.println("Failed to modify default style sheet");
        }
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));
                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

From source file:EditorPaneExample13.java

public EditorPaneExample13() {
    super("JEditorPane Example 13");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/* w  w w. java2  s.com*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Load a new default style sheet
    InputStream is = EditorPaneExample13.class.getResourceAsStream("changedDefault.css");
    if (is != null) {
        try {
            StyleSheet ss = loadStyleSheet(is);
            editorKit.setStyleSheet(ss);
        } catch (IOException e) {
            System.out.println("Failed to load new default style sheet");
        }
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));
                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

From source file:ec.ui.view.RevisionSaSeriesView.java

/**
 * Constructs a new view//from   w  w  w.ja v  a  2  s .  c om
 */
public RevisionSaSeriesView() {
    setLayout(new BorderLayout());

    sRenderer = new XYLineAndShapeRenderer();
    sRenderer.setBaseShapesVisible(false);
    //sRenderer.setSeriesStroke(1, new BasicStroke(0.75f, 1, 1, 1.0f, new float[]{2f, 3f}, 0.0f));
    sRenderer.setBasePaint(themeSupport.getLineColor(ColorScheme.KnownColor.RED));

    revRenderer = new XYLineAndShapeRenderer(false, true);

    mainChart = createMainChart();

    chartpanel_ = new JChartPanel(ChartFactory.createLineChart(null, null, null, null, PlotOrientation.VERTICAL,
            false, false, false));

    documentpanel_ = ComponentFactory.getDefault().newHtmlView();

    JSplitPane splitpane = NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, chartpanel_,
            NbComponents.newJScrollPane(documentpanel_));
    splitpane.setDividerLocation(0.5);
    splitpane.setResizeWeight(.5);

    popup = new ChartPopup(null, false);

    chartpanel_.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent e) {
            if (lastIndexSelected != -1) {
                revRenderer.setSeriesShapesFilled(lastIndexSelected, false);
            }
            if (e.getEntity() != null) {
                if (e.getEntity() instanceof XYItemEntity) {
                    XYItemEntity item = (XYItemEntity) e.getEntity();
                    if (item.getDataset().equals(mainChart.getXYPlot().getDataset(REV_INDEX))) {
                        int i = item.getSeriesIndex();

                        revRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6));
                        revRenderer.setSeriesShapesFilled(i, true);
                        revRenderer.setSeriesPaint(i, themeSupport.getLineColor(ColorScheme.KnownColor.BLUE));

                        lastIndexSelected = i;

                        showRevisionPopup(e);
                    }
                }
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
        }
    });

    chartpanel_.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(JChartPanel.ZOOM_SELECTION_CHANGED)) {
                showSelectionPopup((Rectangle2D) evt.getNewValue());
            }
        }
    });

    this.add(splitpane, BorderLayout.CENTER);
    splitpane.setResizeWeight(0.5);

    onColorSchemeChange();
}

From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.GeneManiaSubInspector.java

private void registerDownloadListener() {
    try {//from  www  .jav  a  2s .c  o  m
        DownloadTask downloadTask = GenemaniaInfoRetriever.getGeneManiaDownloadTask();
        if (currentDownloadTask != downloadTask) {
            currentDownloadTask = downloadTask;

            final DownloadTask dt = downloadTask;
            dt.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("downloadState")) {
                        DownloadState ds = (DownloadState) evt.getNewValue();
                        if (ds == DownloadState.CANCELLED) {
                            panel.removeAll();
                            panel.add(downloadGeneManiaButton);
                            panel.revalidate();
                            panel.repaint();
                        } else if (ds == DownloadState.FINISHED) {
                            //this should always be true.
                            if (DirectorySettings.isGeneManiaInstalled()) {
                                try {
                                    dataPresent = true;
                                    genemania = new GenemaniaInfoRetriever();
                                    genemaniaSettings = new GeneManiaSettingsDialog(genemania);
                                    panel.removeAll();
                                    buildPanel();
                                    updateRelatedGenesPanel(genes);
                                } catch (IOException e) {
                                    DialogUtils.displayMessage("Error downloading GeneMANIA files");
                                    LOG.error("Error downloading GeneMANIA files " + e);
                                    dataPresent = false;
                                }
                            } else {
                                LOG.error("Error downloading GeneMANIA files.");
                            }
                        }
                    }
                }
            });
        }
    } catch (IOException e) {
    }
}

From source file:org.apache.sling.ide.eclipse.ui.internal.InstallEditorSection.java

public void init(IEditorSite site, IEditorInput input) {
    super.init(site, input);

    serverListener = new PropertyChangeListener() {

        @Override/*from w w  w .java2  s. c o  m*/
        public void propertyChange(PropertyChangeEvent evt) {

            if (ISlingLaunchpadServer.PROP_INSTALL_LOCALLY.equals(evt.getPropertyName())) {
                quickLocalInstallButton.setSelection((Boolean) evt.getNewValue());
                bundleLocalInstallButton.setSelection(!(Boolean) evt.getNewValue());
            } else if (evt.getPropertyName()
                    .equals(String.format(ISlingLaunchpadServer.PROP_BUNDLE_VERSION_FORMAT,
                            EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME))) {

                Version launchpadVersion = new Version((String) evt.getNewValue());
                Version embeddedVersion = new Version(artifactLocator.loadToolingSupportBundle().getVersion());

                updateActionArea(launchpadVersion, embeddedVersion);
            }
        }
    };

    server.addPropertyChangeListener(serverListener);

    launchpadServer = (ISlingLaunchpadServer) server.getAdapter(ISlingLaunchpadServer.class);
    if (launchpadServer == null) {
        // TODO progress monitor
        launchpadServer = (ISlingLaunchpadServer) server.loadAdapter(ISlingLaunchpadServer.class,
                new NullProgressMonitor());
    }

    artifactLocator = Activator.getDefault().getArtifactLocator();
    osgiClientFactory = Activator.getDefault().getOsgiClientFactory();
}

From source file:org.squidy.designer.zoom.ActionShape.java

@Override
public void initialize() {
    super.initialize();

    if (getProcessable() != null) {
        // Add property change listener that allows to start valve
        // processing this way.
        getProcessable().addStatusChangeListener(Processable.PROPERTY_PROCESSING, new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent evt) {
                firePropertyChange(0, Processable.PROPERTY_PROCESSING, evt.getOldValue(), evt.getNewValue());
            }/*from w  w w  .  j ava  2  s .co  m*/
        });

        getProcessable().addStatusChangeListener(Processable.STATUS_PROCESSABLE_DELETED,
                new PropertyChangeListener() {

                    public void propertyChange(PropertyChangeEvent evt) {
                        if (Pipe.class.isAssignableFrom(evt.getOldValue().getClass()))
                            return;
                        removeFromParent();
                    }
                });

        getProcessable().addStatusChangeListener(Processable.PROPERTY_FAILURE_PUBLISH,
                new PropertyChangeListener() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see
                     * java.beans.PropertyChangeListener#propertyChange(
                     * java.beans.PropertyChangeEvent)
                     */
                    public void propertyChange(PropertyChangeEvent evt) {
                        Throwable e = (Throwable) evt.getNewValue();
                        publishFailure(e);
                    }
                });

        getProcessable().addStatusChangeListener(Processable.PROPERTY_FAILURE_RESOLVE,
                new PropertyChangeListener() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see
                     * java.beans.PropertyChangeListener#propertyChange(
                     * java.beans.PropertyChangeEvent)
                     */
                    public void propertyChange(PropertyChangeEvent evt) {
                        resolveFailure();

                        // for (Object o : getChildrenReference()) {
                        // if (o instanceof ZoomActionShape) {
                        // ((ZoomActionShape<?>) o).resolveFailure();
                        // }
                        // }
                    }
                });

        getProcessable().addStatusChangeListener(Processable.PROPERTY_NOTIFICATION,
                new PropertyChangeListener() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see
                     * java.beans.PropertyChangeListener#propertyChange(
                     * java.beans.PropertyChangeEvent)
                     */
                    public void propertyChange(PropertyChangeEvent evt) {
                        publishNotification(new TemporaryNotification(evt.getNewValue().toString()));
                    }
                });
    }
}

From source file:EditorPaneExample16.java

public EditorPaneExample16() {
    super("JEditorPane Example 16");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*from  www.j a  v  a2 s  . c  o m*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));
                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

From source file:cz.lbenda.coursing.client.gui.LoginForm.java

public static void showLoginDialog() {
    final LoginForm form = new LoginForm();
    JButton login = new JButton();
    login.setText("Login"); // FIXME localizable
    JButton cancel = new JButton();
    cancel.setText("Cancel"); // FIXME localizable

    cancel.addActionListener(new ActionListener() {
        @Override/*from   w  w w.  java2  s .com*/
        public void actionPerformed(ActionEvent e) {
            exit();
        }
    });

    login.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                SecurityService ss = (SecurityService) ClientServiceLocator.getInstance()
                        .getBean(SecurityService.SERVICE_NAME);
                ss.login(form.getUsername(), form.getPassword());
            } catch (AuthenticationException ex) {
                NotifyDescriptor info = new NotifyDescriptor.Message(ex.getLocalizedMessage(),
                        NotifyDescriptor.INFORMATION_MESSAGE);
                DialogDisplayer.getDefault().notify(info);
                LoginForm.showLoginDialog();
            }
        }
    });

    NotifyDescriptor nd = new NotifyDescriptor.Confirmation(form, Bundle.CTL_LoginForm());
    nd.setOptions(new Object[] { login, cancel });
    nd.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (NotifyDescriptor.CLOSED_OPTION.equals(evt.getNewValue())) {
                exit();
            }
        }
    });
    DialogDisplayer.getDefault().notifyLater(nd);
}

From source file:com.github.alexfalappa.nbspringboot.projects.service.spi.SpringBootServiceImpl.java

private void init() {
    if (mvnPrj == null) {
        return;/* w w w . j  a va2s . c om*/
    }
    logger.info("Initializing SpringBoot service");
    // check maven project has a dependency starting with 'spring-boot'
    logger.fine("Checking maven project has a spring boot dependency");
    springBootAvailable = dependencyArtifactIdContains(mvnPrj.getProjectWatcher(), "spring-boot");
    // early exit if no spring boot dependency detected
    if (!springBootAvailable) {
        return;
    }
    logger.log(INFO, "Initializing SpringBootService for project {0}", new Object[] { mvnPrj.toString() });
    // set up a reference to the execute classpath object
    Sources srcs = ProjectUtils.getSources(mvnPrj);
    SourceGroup[] srcGroups = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    boolean srcGroupFound = false;
    for (SourceGroup group : srcGroups) {
        if (group.getName().toLowerCase().contains("source")) {
            srcGroupFound = true;
            cpExec = ClassPath.getClassPath(group.getRootFolder(), ClassPath.EXECUTE);
            break;
        }
    }
    if (!srcGroupFound) {
        logger.log(WARNING, "No sources found for project: {0}", new Object[] { mvnPrj.toString() });
    }
    if (cpExec != null) {
        // check if completion of configuration properties is possible
        try {
            logger.fine(
                    "Checking spring boot ConfigurationProperties class is on the project execution classpath");
            cpExec.getClassLoader(false)
                    .loadClass("org.springframework.boot.context.properties.ConfigurationProperties");
        } catch (ClassNotFoundException ex) {
            // no completion
        }
        // listen for pom changes
        logger.info("Adding maven pom listener...");
        mvnPrj.getProjectWatcher().addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                final String propertyName = String.valueOf(evt.getPropertyName());
                logger.log(FINE, "Maven pom change ({0})", propertyName);
                if (propertyName.equals("MavenProject")) {
                    refresh();
                }
            }
        });
        // build configuration properties maps
        updateConfigRepo();
    }
}

From source file:VASSAL.chat.node.NodeClient.java

public NodeClient(String moduleName, String playerId, CommandEncoder encoder, MessageBoard msgSvr,
        WelcomeMessageServer welcomer) {
    this.encoder = encoder;
    this.msgSvr = msgSvr;
    this.welcomer = welcomer;
    this.playerId = playerId;
    this.moduleName = moduleName;
    serverStatus = new CgiServerStatus();
    me = new NodePlayer(playerId);
    messageBoardControls = new MessageBoardControlsInitializer(Resources.getString("Chat.messages"), msgSvr); //$NON-NLS-1$
    roomControls = new LockableNodeRoomControls(this);
    roomControls.addPlayerActionFactory(ShowProfileAction.factory());
    roomControls.addPlayerActionFactory(SynchAction.factory(this));
    PrivateChatManager privateChatManager = new PrivateChatManager(this);
    roomControls.addPlayerActionFactory(PrivateMessageAction.factory(this, privateChatManager));
    roomControls.addPlayerActionFactory(SendSoundAction.factory(this, Resources.getString("Chat.send_wakeup"), //$NON-NLS-1$
            "wakeUpSound", "phone1.wav")); //$NON-NLS-1$ //$NON-NLS-2$
    roomControls.addPlayerActionFactory(InviteAction.factory(this));
    roomControls.addPlayerActionFactory(KickAction.factory(this));
    serverStatusControls = new ServerStatusControlsInitializer(serverStatus);
    playerStatusControls = new SimpleStatusControlsInitializer(this);
    synchEncoder = new SynchEncoder(this, this);
    privateChatEncoder = new PrivateChatEncoder(this, privateChatManager);
    soundEncoder = new SoundEncoder(this);
    inviteEncoder = new InviteEncoder(this);
    nameChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            SimplePlayer p = (SimplePlayer) getUserInfo();
            p.setName((String) evt.getNewValue());
            setUserInfo(p);//from ww  w  .  j  a v a 2 s  . c  o  m
        }
    };
    profileChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            SimplePlayer p = (SimplePlayer) getUserInfo();
            SimpleStatus s = (SimpleStatus) p.getStatus();
            s = new SimpleStatus(s.isLooking(), s.isAway(), (String) evt.getNewValue(), s.getClient(),
                    s.getIp(), s.getModuleVersion(), s.getCrc());
            p.setStatus(s);
            setUserInfo(p);
        }
    };
}