Java Code Examples for javax.swing.event.HyperlinkEvent#getSource()
The following examples show how to use
javax.swing.event.HyperlinkEvent#getSource() .
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: GHelpHTMLEditorKit.java From ghidra with Apache License 2.0 | 6 votes |
/** Generates a new event with a URL based upon Ghidra's resources if needed. */ private HyperlinkEvent maybeCreateNewHyperlinkEventWithUpdatedURL(HyperlinkEvent event) { Element element = event.getSourceElement(); if (element == null) { return event;// this shouldn't happen since we were triggered from an A tag } AttributeSet a = element.getAttributes(); AttributeSet anchor = (AttributeSet) a.getAttribute(HTML.Tag.A); if (anchor == null) { return event;// this shouldn't happen since we were triggered from an A tag } String HREF = (String) anchor.getAttribute(HTML.Attribute.HREF); Msg.trace(this, "HREF of <a> tag: " + HREF); URL newUrl = getURLForHREFFromResources(HREF); if (newUrl == null) { return event;// unable to locate a resource by the name--bad link! } return new HyperlinkEvent(event.getSource(), event.getEventType(), newUrl, event.getDescription(), event.getSourceElement()); }
Example 2
Source File: HTMLPanel.java From littleluck with Apache License 2.0 | 6 votes |
public void hyperlinkUpdate(HyperlinkEvent event) { JEditorPane descriptionPane = (JEditorPane) event.getSource(); HyperlinkEvent.EventType type = event.getEventType(); if (type == HyperlinkEvent.EventType.ACTIVATED) { try { DemoUtilities.browse(event.getURL().toURI()); } catch (Exception e) { e.printStackTrace(); System.err.println(e); } } else if (type == HyperlinkEvent.EventType.ENTERED) { defaultCursor = descriptionPane.getCursor(); descriptionPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else if (type == HyperlinkEvent.EventType.EXITED) { descriptionPane.setCursor(defaultCursor); } }
Example 3
Source File: HTMLPanel.java From beautyeye with Apache License 2.0 | 6 votes |
public void hyperlinkUpdate(HyperlinkEvent event) { JEditorPane descriptionPane = (JEditorPane) event.getSource(); HyperlinkEvent.EventType type = event.getEventType(); if (type == HyperlinkEvent.EventType.ACTIVATED) { try { DemoUtilities.browse(event.getURL().toURI()); } catch (Exception e) { e.printStackTrace(); System.err.println(e); } } else if (type == HyperlinkEvent.EventType.ENTERED) { defaultCursor = descriptionPane.getCursor(); descriptionPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else if (type == HyperlinkEvent.EventType.EXITED) { descriptionPane.setCursor(defaultCursor); } }
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: HTMLPanel.java From Darcula with Apache License 2.0 | 6 votes |
public void hyperlinkUpdate(HyperlinkEvent event) { JEditorPane descriptionPane = (JEditorPane) event.getSource(); HyperlinkEvent.EventType type = event.getEventType(); if (type == HyperlinkEvent.EventType.ACTIVATED) { try { DemoUtilities.browse(event.getURL().toURI()); } catch (Exception e) { e.printStackTrace(); System.err.println(e); } } else if (type == HyperlinkEvent.EventType.ENTERED) { defaultCursor = descriptionPane.getCursor(); descriptionPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else if (type == HyperlinkEvent.EventType.EXITED) { descriptionPane.setCursor(defaultCursor); } }
Example 6
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 7
Source File: DesktopUtil.java From jeveassets with GNU General Public License v2.0 | 5 votes |
@Override public void hyperlinkUpdate(final HyperlinkEvent hle) { Object o = hle.getSource(); if (o instanceof JEditorPane) { JEditorPane jEditorPane = (JEditorPane) o; if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType()) && jEditorPane.isEnabled()) { browse(hle.getURL().toString(), window); } } }
Example 8
Source File: EditableNotificationMessageElement.java From consulo with Apache License 2.0 | 5 votes |
private static void disableLink(@Nonnull final HyperlinkEvent event, @Nullable final String linkText) { if (event.getSource() instanceof MyJEditorPane) { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { final MyJEditorPane editorPane = (MyJEditorPane)event.getSource(); editorPane.myElement.addDisabledLink(event.getDescription(), linkText); editorPane.myElement.updateStyle(editorPane, null, null, true, false); } }); } }