本文整理汇总了Java中javax.swing.event.HyperlinkEvent.getURL方法的典型用法代码示例。如果您正苦于以下问题:Java HyperlinkEvent.getURL方法的具体用法?Java HyperlinkEvent.getURL怎么用?Java HyperlinkEvent.getURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.HyperlinkEvent
的用法示例。
在下文中一共展示了HyperlinkEvent.getURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHyperlinkListener
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public static HyperlinkListener createHyperlinkListener() {
return new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent hlevt) {
if (HyperlinkEvent.EventType.ACTIVATED == hlevt.getEventType()) {
final URL url = hlevt.getURL();
if (url != null) {
try {
openBrowser(url.toURI());
} catch (URISyntaxException e) {
LogManager.log(e);
}
}
}
}
};
}
示例2: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
url = hyperlinkEvent.getURL();
HyperlinkEvent.EventType type = hyperlinkEvent.getEventType();
if (type == HyperlinkEvent.EventType.ENTERED) {
isInsideHyperlink = true;
pane.setToolTipText(getURLExternalForm()); // #176141
}
else if (type == HyperlinkEvent.EventType.ACTIVATED) {
isInsideHyperlink = false;
pane.setToolTipText(null);
}
else if (type == HyperlinkEvent.EventType.EXITED) {
isInsideHyperlink = false;
pane.setToolTipText(null);
}
else {
Installer.log.log(Level.SEVERE, "Unknown hyperlinkEvent: " +
hyperlinkEvent);
}
}
示例3: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
@Override
public void hyperlinkUpdate (HyperlinkEvent event)
{
HyperlinkEvent.EventType type = event.getEventType();
final URL url = event.getURL();
if (type == HyperlinkEvent.EventType.ACTIVATED) {
try {
//System.out.println("Activated URL " + url);
URI uri = new URI(url.toString());
WebBrowser.getBrowser().launch(uri);
} catch (URISyntaxException ex) {
logger.warn("Illegal URI " + url, ex);
}
}
}
示例4: 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();
}
}
}
}
示例5: createLinkEnabledEditorPane
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public static JEditorPane createLinkEnabledEditorPane(final Component parent,
String text) {
JEditorPane pane = createEditorPane(text);
HyperlinkListener linkListener = new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
URL url = e.getURL();
if (!openBrowser(e.getURL())) {
JOptionPane.showMessageDialog(parent,
"An error occurred while opening the URL: " + url.toString(),
"Error", JOptionPane.ERROR_MESSAGE);
}
}
}
};
pane.addHyperlinkListener(linkListener);
return pane;
}
示例6: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent event) {
if(HyperlinkEvent.EventType.ENTERED == event.getEventType()) {
url = event.getURL();
} else if (HyperlinkEvent.EventType.EXITED == event.getEventType()) {
url = null;
}
}
示例7: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent e) {
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
if (e.getURL() != null) {
update(e.getURL());
}
}
}
示例8: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
return;
}
final String desc = event.getDescription();
if ((!isURL() && desc.indexOf('/') < 0) || event.getURL() == null) {
final int hash = desc.lastIndexOf("#");
if (hash < 0) {
// no anchor
setFile(desc);
}
else if (hash > 0) {
// browse to the part before the anchor
setFile(desc.substring(0, hash));
}
if (hash != -1) {
// we have an anchor
htmlWin.scrollToReference(desc.substring(hash+1));
}
}
else {
try {
htmlWin.setPage(event.getURL());
}
catch (IOException ex) {
ReadErrorDialog.error(ex, event.getURL().toString());
}
htmlWin.revalidate();
}
}
示例9: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
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);
}
}
示例10: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
@Override
public void hyperlinkUpdate(final HyperlinkEvent event) {
URI uri = null;
try {
final URL url = event.getURL();
uri = url.toURI(); //NOPMD
} catch (final URISyntaxException exception) {
LOGGER.logError("An logError occurred while retrieving URI: %s", exception);
}
if (isClicked(event)) {
browseTo(uri);
}
}
示例11: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (e.getURL() == null) {
try (InputStream is = FileUtils.getResourceInputStream("/licenses/" + e.getDescription())) {
new TextDialog("License - " + e.getDescription().substring(0, e.getDescription().indexOf('.')), FileUtils.convertStreamToString(is), true).showDialog();
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
JHVGlobals.openURL(e.getURL().toString());
}
}
}
示例12: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (e.getURL() == null) {
Plugin p = plugin.getPlugin();
String text = "<center><p><big><b>" + p.getName() + "</b></big></p><p><b>Plug-in description</b><br/>" + p.getDescription() +
"</p><p><b>Plug-in license information</b><br/>" + p.getAboutLicenseText();
new TextDialog("About", text, false).showDialog();
} else {
JHVGlobals.openURL(e.getURL().toString());
}
}
}
示例13: hyperlinkActivated
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
URL url = event.getURL();
if (url == null) {
BrowserUtil.browse(event.getDescription());
}
else {
BrowserUtil.browse(url);
}
if (myExpireNotification) {
notification.expire();
}
}
示例14: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public @Override void hyperlinkUpdate(HyperlinkEvent evt) {
if (EventType.ACTIVATED == evt.getEventType() && evt.getURL() != null) {
HtmlBrowser.URLDisplayer.getDefault().showURL(evt.getURL());
}
}
示例15: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入方法依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent evt) {
if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
new LoaderThread(evt.getURL());
}
}