Java Code Examples for javax.swing.event.HyperlinkEvent.EventType#ACTIVATED

The following examples show how to use javax.swing.event.HyperlinkEvent.EventType#ACTIVATED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebViewHyperlinkListenerDemo.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Visualizes the specified event's type and URL on the specified label.
 *
 * @param event
 *            the {@link HyperlinkEvent} to visualize
 * @param urlLabel
 *            the {@link Label} which will visualize the event
 */
private static void showEventOnLabel(HyperlinkEvent event, Label urlLabel) {
	if (event.getEventType() == EventType.ENTERED) {
		urlLabel.setTextFill(Color.BLACK);
		urlLabel.setText("ENTERED: " + event.getURL().toExternalForm());
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	} else if (event.getEventType() == EventType.EXITED) {
		urlLabel.setTextFill(Color.BLACK);
		urlLabel.setText("EXITED: " + event.getURL().toExternalForm());
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	} else if (event.getEventType() == EventType.ACTIVATED) {
		urlLabel.setText("ACTIVATED: " + event.getURL().toExternalForm());
		urlLabel.setTextFill(Color.RED);
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	}
}
 
Example 2
Source File: OverviewBuilder.java    From raccoon4 with Apache License 2.0 6 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
	if (INSTALL.equals(e.getDescription())) {
		if (e.getEventType() == EventType.ACTIVATED) {
			TransferWorker w = new FetchToolsWorker(globals);
			globals.get(TransferManager.class).schedule(globals, w,
					TransferManager.WAN);
		}
	}
	else {
		if (e.getEventType() == EventType.ACTIVATED) {
			try {
				BrowseAction.open(e.getURL().toURI());
			}
			catch (Exception e1) {
				e1.printStackTrace();
			}
		}
	}
}
 
Example 3
Source File: SimpleBrowser.java    From WorldPainter with GNU General Public License v3.0 6 votes vote down vote up
private void jEditorPane1HyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_jEditorPane1HyperlinkUpdate
    if (evt.getEventType() == EventType.ACTIVATED) {
        URL url = evt.getURL();
        try {
            jEditorPane1.setPage(url);
            if (historyPointer == (historySize - 1)) {
                // At the end of the history
                history.add(url.toExternalForm());
                historyPointer++;
                historySize++;
            } else {
                // Not at the end of the history; erase the tail end
                historyPointer++;
                history.set(historyPointer, url.toExternalForm());
                historySize = historyPointer + 1;
            }
            backAction.setEnabled(true);
            forwardAction.setEnabled(false);
        } catch (IOException e) {
            JOptionPane.showMessageDialog(this, "I/O error loading page " + url, "Error Loading Page", JOptionPane.ERROR_MESSAGE);
        }
    }
}
 
Example 4
Source File: LinkButton.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private void makeHyperLinkListener(final Action action) {
	actionLinkListener = new HyperlinkListener() {

		@Override
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == EventType.ACTIVATED) {
				action.actionPerformed(
						new ActionEvent(LinkButton.this, ActionEvent.ACTION_PERFORMED, e.getDescription()));
			}
		}
	};
	addHyperlinkListener(actionLinkListener);
}
 
Example 5
Source File: AbstractLinkButton.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates the hyperlink listener for the given action.
 *
 * @param action
 */
private void makeHyperLinkListener(final Action action) {

	actionLinkListener = new HyperlinkListener() {

		@Override
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == EventType.ACTIVATED) {
				action.actionPerformed(
						new ActionEvent(AbstractLinkButton.this, ActionEvent.ACTION_PERFORMED, e.getDescription()));
			}
		}
	};
	addHyperlinkListener(actionLinkListener);
}
 
Example 6
Source File: FullAppDescriptionBuilder.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
	if (e.getEventType() == EventType.ACTIVATED) {
		if (ALLAPPS.equals(e.getDescription())) {
			globals.get(PlayManager.class).searchApps(current.getCreator());
		}
	}
}
 
Example 7
Source File: AboutDialog.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
private void jTextPane1HyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_jTextPane1HyperlinkUpdate
    if (evt.getEventType() == EventType.ACTIVATED) {
        URL url = evt.getURL();
        if (url.getProtocol().equals("action")) { // NOI18N
            String action = url.getPath().toLowerCase().trim();
            if (action.equals("/donate")) { // NOI18N
                donate();
            }
        } else {
            DesktopUtils.open(url);
        }
    }
}
 
Example 8
Source File: SimpleBrowser.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    if ((e.getEventType() == EventType.ACTIVATED) && (e.getURL().getProtocol().equals("action")) && (actionListener != null)) {
        ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, e.getURL().getFile());
        actionListener.actionPerformed(event);
    }
}
 
Example 9
Source File: TemplatesPanelGUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public @Override void hyperlinkUpdate(HyperlinkEvent evt) {
    if (EventType.ACTIVATED == evt.getEventType() && evt.getURL() != null) {
        HtmlBrowser.URLDisplayer.getDefault().showURL(evt.getURL());
    }
}