本文整理汇总了Java中javax.swing.event.HyperlinkEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java HyperlinkEvent.getSource方法的具体用法?Java HyperlinkEvent.getSource怎么用?Java HyperlinkEvent.getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.HyperlinkEvent
的用法示例。
在下文中一共展示了HyperlinkEvent.getSource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
@Override
public void hyperlinkUpdate(final HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
final JEditorPane pane = (JEditorPane) e.getSource();
if (e instanceof HTMLFrameHyperlinkEvent) {
final HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
final HTMLDocument doc = (HTMLDocument) pane.getDocument();
doc.processHTMLFrameHyperlinkEvent(evt);
} else {
try {
pane.setPage(e.getURL());
} catch (final Throwable t) {
MessageBox.showError(HtmlViewer.this.getParent(), t.getMessage());
}
}
}
}
示例2: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
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 {
URL nurl = e.getURL();
if (nurl == null) nurl = new URL(m_baseurl, e.getDescription());
if (jsmooth.Native.isAvailable()) {
jsmooth.Native.shellExecute(jsmooth.Native.SHELLEXECUTE_OPEN, nurl.toString(), null, null, jsmooth.Native.SW_NORMAL);
} else
m_launcher.openURLinBrowser(nurl.toExternalForm());
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}
示例3: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
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);
}
}
示例4: disableLink
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
private static void disableLink(@NotNull 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);
}
});
}
}
示例5: openFatals
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
private static void openFatals(HyperlinkEvent event, LogMessage message) {
Object source = event.getSource();
if (source instanceof Component) {
Window window = SwingUtilities.getWindowAncestor((Component)source);
if (window instanceof IdeFrame) {
final StatusBar statusBar = ((IdeFrame)window).getStatusBar();
StatusBarWidget widget = statusBar == null ? null : statusBar.getWidget(IdeMessagePanel.FATAL_ERROR);
if (widget instanceof IdeMessagePanel) {
((IdeMessagePanel)widget).openFatals(message);
}
}
}
}
示例6: RenderErrorPanel
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public RenderErrorPanel() {
super(new BorderLayout());
setOpaque(false);
myHTMLViewer = new JEditorPane(UIUtil.HTML_MIME, "<HTML><BODY>Render Problems</BODY></HTML>");
myHTMLViewer.setEditable(false);
myHyperLinkListener = new HyperlinkListener() {
@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);
return;
}
String url = e.getDescription();
if (url.equals(URL_ACTION_CLOSE)) {
close();
return;
}
performClick(url);
}
}
};
myHTMLViewer.addHyperlinkListener(myHyperLinkListener);
myHTMLViewer.setMargin(new Insets(3, 3, 3, 3));
myScrollPane = ScrollPaneFactory.createScrollPane(myHTMLViewer);
setupStyle();
add(myScrollPane, BorderLayout.CENTER);
}