本文整理汇总了Java中javax.jnlp.BasicService.showDocument方法的典型用法代码示例。如果您正苦于以下问题:Java BasicService.showDocument方法的具体用法?Java BasicService.showDocument怎么用?Java BasicService.showDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jnlp.BasicService
的用法示例。
在下文中一共展示了BasicService.showDocument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: browse
import javax.jnlp.BasicService; //导入方法依赖的package包/类
public static boolean browse(URI uri) throws IOException , UnavailableServiceException {
// Try using the Desktop api first
try {
Desktop desktop = Desktop.getDesktop();
desktop.browse(uri);
return true;
} catch (SecurityException e) {
// Running in sandbox, try using WebStart service
BasicService basicService =
(BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
if (basicService.isWebBrowserSupported()) {
return basicService.showDocument(uri.toURL());
}
}
return false;
}
示例2: showDocument
import javax.jnlp.BasicService; //导入方法依赖的package包/类
/**
* Tries to open passed URL in system browser
* using JNLP BasicService
*/
public static boolean showDocument(String url) {
URL url2Show = null;
try {
url2Show = new java.net.URL(url);
} catch (MalformedURLException ex) {
// nothing much to do here
}
BasicService service = getBasicService();
if (service != null) {
return service.showDocument(url2Show);
}
return false;
}
示例3: showURL
import javax.jnlp.BasicService; //导入方法依赖的package包/类
public static boolean showURL( URL url ) {
try {
// Lookup the javax.jnlp.BasicService object
BasicService bs = (BasicService) ServiceManager.lookup( "javax.jnlp.BasicService" );
// Invoke the showDocument method
return bs.showDocument( url );
}
catch ( UnavailableServiceException ue ) {
// Service is not supported
return false;
}
}