Java Code Examples for javax.swing.event.HyperlinkEvent#getEventType()
The following examples show how to use
javax.swing.event.HyperlinkEvent#getEventType() .
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: HTMLDialogBox.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
/** * Turns HTML into a clickable dialog text component. * @param html String of valid HTML. * @return a JTextComponent with the HTML inside. */ public JTextComponent createHyperlinkListenableJEditorPane(String html) { final JEditorPane bottomText = new JEditorPane(); bottomText.setContentType("text/html"); bottomText.setEditable(false); bottomText.setText(html); bottomText.setOpaque(false); final HyperlinkListener hyperlinkListener = new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(hyperlinkEvent.getURL().toURI()); } catch (IOException | URISyntaxException exception) { // Auto-generated catch block exception.printStackTrace(); } } } } }; bottomText.addHyperlinkListener(hyperlinkListener); return bottomText; }
Example 2
Source File: InfoPaneLinkAction.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { DesktopBrowserLauncher.viewInBrowser(e.getURL()); } catch (IOException e1) { Logging.errorPrint("Failed to open URL " //$NON-NLS-1$ + e.getURL() + " due to ", e1); //$NON-NLS-1$ ShowMessageDelegate.showMessageDialog( LanguageBundle.getFormattedString("in_Src_browser", e //$NON-NLS-1$ .getURL().toString()), Constants.APPLICATION_NAME, MessageType.ERROR); } } }
Example 3
Source File: HomeView.java From javamoney-examples with Apache License 2.0 | 6 votes |
public void hyperlinkUpdate(HyperlinkEvent event) { if(event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { String command = event.getDescription(); if(command.equals(ACTION_EDIT) == true) { PreferencesDialog.showPreferencesDialog(PreferencesKeys.ACCOUNTS); } else { // Get the account reference. Account account = (Account)getAccounts().get(command); // Show the account's register. getFrame().getViews().openRegisterFor(account); } } }
Example 4
Source File: DefaultHyperlinkHandler.java From SwingBox with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent evt) { JEditorPane pane = (JEditorPane) evt.getSource(); if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { setCursor(pane, DefaultCursor); loadPage(pane, evt); } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { regionEntered(pane, evt); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { regionExited(pane, evt); } }
Example 5
Source File: EditorPaneDemo.java From littleluck with Apache License 2.0 | 6 votes |
private HyperlinkListener createHyperLinkListener() { return new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e instanceof HTMLFrameHyperlinkEvent) { ((HTMLDocument) html.getDocument()).processHTMLFrameHyperlinkEvent( (HTMLFrameHyperlinkEvent) e); } else { try { html.setPage(e.getURL()); } catch (IOException ioe) { System.out.println("IOE: " + ioe); } } } } }; }
Example 6
Source File: ReportDisplay.java From megamek with GNU General Public License v2.0 | 6 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent evt) { if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { String evtDesc = evt.getDescription(); if (evtDesc.startsWith("#entity")) { String idString = evtDesc.substring(evtDesc.indexOf(":") + 1); int id; try { id = Integer.parseInt(idString); } catch (Exception ex) { id = -1; } Entity ent = clientgui.getClient().getGame().getEntity(id); if (ent != null) { clientgui.mechD.displayEntity(ent); clientgui.setDisplayVisible(true); } } } }
Example 7
Source File: NotificationsUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static HyperlinkListener wrapListener(@Nonnull final Notification notification) { final NotificationListener listener = notification.getListener(); if (listener == null) return null; return new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { final NotificationListener listener1 = notification.getListener(); if (listener1 != null) { listener1.hyperlinkUpdate(notification, e); } } } }; }
Example 8
Source File: ManualHandler.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane pane = (JEditorPane) e.getSource(); if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e; HTMLDocument doc = (HTMLDocument) pane.getDocument(); doc.processHTMLFrameHyperlinkEvent(evt); } else { try { pane.setPage(e.getURL()); } catch (Throwable t) { t.printStackTrace(); } } } }
Example 9
Source File: EditorPaneDemo.java From beautyeye with Apache License 2.0 | 6 votes |
private HyperlinkListener createHyperLinkListener() { return new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e instanceof HTMLFrameHyperlinkEvent) { ((HTMLDocument) html.getDocument()).processHTMLFrameHyperlinkEvent( (HTMLFrameHyperlinkEvent) e); } else { try { html.setPage(e.getURL()); } catch (IOException ioe) { System.out.println("IOE: " + ioe); } } } } }; }
Example 10
Source File: SwingBrowserWindow.java From molicode with Apache License 2.0 | 5 votes |
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { Desktop desktop = Desktop.getDesktop(); try { desktop.browse(e.getURL().toURI()); } catch (IOException var4) { var4.printStackTrace(); } catch (URISyntaxException var5) { var5.printStackTrace(); } } }
Example 11
Source File: Help.java From FancyBing with GNU General Public License v3.0 | 5 votes |
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL url = e.getURL(); String protocol = url.getProtocol(); if (protocol.equals("jar") || protocol.equals("file")) { loadURL(url); appendHistory(url); } else openExternal(url); } }
Example 12
Source File: LibraryTreePanel.java From osp with GNU General Public License v3.0 | 5 votes |
public void hyperlinkUpdate(HyperlinkEvent e) { if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED) { try { // try the preferred way if (!org.opensourcephysics.desktop.OSPDesktop.browse(e.getURL().toURI())) { // try the old way org.opensourcephysics.desktop.ostermiller.Browser.init(); org.opensourcephysics.desktop.ostermiller.Browser.displayURL(e.getURL().toString()); } } catch(Exception ex) {} } }
Example 13
Source File: ReportWindow.java From Rails with GNU General Public License v2.0 | 5 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && ! isStatic ) { activateTimeWarp(); URL url = e.getURL(); int index = url.getPort(); gotoIndex(index); toFront(); } }
Example 14
Source File: EditableNotificationMessageElement.java From consulo with Apache License 2.0 | 5 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { final NotificationListener notificationListener = myNotification.getListener(); if (notificationListener != null) { notificationListener.hyperlinkUpdate(myNotification, e); } } }
Example 15
Source File: SummaryInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { // We get two messages on a click, so ignore duplicates if (lastDest.equals(e.getDescription())) { lastDest = ""; //$NON-NLS-1$ return; } lastDest = e.getDescription(); firePropertyChange(TodoFacade.SWITCH_TABS, "", e.getDescription()); //$NON-NLS-1$ } }
Example 16
Source File: KHtmlEdit.java From stendhal with GNU General Public License v2.0 | 4 votes |
@Override public void hyperlinkUpdate(final HyperlinkEvent ev) { if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { activateLink(ev); } }
Example 17
Source File: ActivatedHyperlinkListener.java From bither-desktop-java with Apache License 2.0 | 4 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { HyperlinkEvent.EventType type = hyperlinkEvent.getEventType(); final URL url = hyperlinkEvent.getURL(); if (type == HyperlinkEvent.EventType.ENTERED) { // Message message = new Message(url.toString(), true); // message.setShowInMessagesTab(false); // MessageManager.INSTANCE.addMessage(message); if (browser.isLoading()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { browser.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } }); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { browser.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } }); } } else if (type == HyperlinkEvent.EventType.EXITED) { // Message message = new Message(SPACER, true); // message.setShowInMessagesTab(false); // MessageManager.INSTANCE.addMessage(message); if (browser.isLoading()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { browser.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } }); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { browser.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); } } else if (type == HyperlinkEvent.EventType.ACTIVATED) { } }
Example 18
Source File: NotificationManager.java From ganttproject with GNU General Public License v3.0 | 4 votes |
@Override public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { BrowserControl.displayURL(hyperlinkEvent.getURL().toString()); } }
Example 19
Source File: BrokenProjectInfo.java From netbeans with Apache License 2.0 | 4 votes |
public void hyperlinkUpdate(HyperlinkEvent evt) { if (HyperlinkEvent.EventType.ACTIVATED == evt.getEventType()) { HtmlBrowser.URLDisplayer.getDefault().showURL(evt.getURL()); } }
Example 20
Source File: TemplatesPanelGUI.java From netbeans with Apache License 2.0 | 4 votes |
public @Override void hyperlinkUpdate(HyperlinkEvent evt) { if (EventType.ACTIVATED == evt.getEventType() && evt.getURL() != null) { HtmlBrowser.URLDisplayer.getDefault().showURL(evt.getURL()); } }