当前位置: 首页>>代码示例>>Java>>正文


Java Desktop.isDesktopSupported方法代码示例

本文整理汇总了Java中java.awt.Desktop.isDesktopSupported方法的典型用法代码示例。如果您正苦于以下问题:Java Desktop.isDesktopSupported方法的具体用法?Java Desktop.isDesktopSupported怎么用?Java Desktop.isDesktopSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Desktop的用法示例。


在下文中一共展示了Desktop.isDesktopSupported方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseClicked

import java.awt.Desktop; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int ccol = table.columnAtPoint(pt);
    int crow = table.rowAtPoint(pt);
    Object value = table.getValueAt(crow, ccol);
    if (value instanceof URL) {
        URL url = (URL) value;
        Desktop desktop = null;
        try {
            if (Desktop.isDesktopSupported()) {
                desktop = Desktop.getDesktop();
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
        if (desktop != null) {
            try {
                desktop.browse(url.toURI());
            } catch (Exception exc) {
                // browsing failed; just don't do anything
            }
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:LibrariesTable.java

示例2: run

import java.awt.Desktop; //导入方法依赖的package包/类
public static void run(String file){
    try {
                    File f = new File(file);
                    if (f.exists()) 
                    {
                        if (Desktop.isDesktopSupported()) 
                        {
                        Desktop.getDesktop().open(f);
                        } 
             
                        else
                        {
                        System.out.println("File does not exists!");
                        }
         
                    } else {
                        System.out.println("File does not exists!");
                    }
                }
                catch(Exception ert)
                {}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:23,代码来源:RunDBrowser.java

示例3: editDESKTOP

import java.awt.Desktop; //导入方法依赖的package包/类
private static boolean editDESKTOP(File file) {

        logOut("Trying to use Desktop.getDesktop().edit() with " + file);
        try {
            if (!Desktop.isDesktopSupported()) {
                logErr("Platform is not supported.");
                return false;
            }

            if (!Desktop.getDesktop().isSupported(Desktop.Action.EDIT)) {
                logErr("EDIT is not supported.");
                return false;
            }

            Desktop.getDesktop().edit(file);

            return true;
        } catch (Throwable t) {
            logErr("Error using desktop edit.", t);
            return false;
        }
    }
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:23,代码来源:DesktopApi.java

示例4: run

import java.awt.Desktop; //导入方法依赖的package包/类
public static void run(){
    try {
                    File f = select.getSelectedFile();
                    if (f.exists()) 
                    {
                        if (Desktop.isDesktopSupported()) 
                        {
                        Desktop.getDesktop().open(f);
                        } 
             
                        else
                        {
                        System.out.println("File does not exists!");
                        }
         
                    } else {
                        System.out.println("File does not exists!");
                    }
                }
                catch(Exception ert)
                {}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:23,代码来源:Run.java

示例5: openWebPage

import java.awt.Desktop; //导入方法依赖的package包/类
private void openWebPage(String webAddress)
{
	try
	{
		if (Desktop.isDesktopSupported())
		{
			URI location = new URI(webAddress);
			Desktop.getDesktop().browse(location);
		}
		else
		{
			String cause = "This JVM does not support Desktop. Try updating Java to the latest version.";
			throw new Exception(cause);
		}
	}
	catch (Exception exception)
	{
		String recoveryMessage = "There was a problem opening the following webpage:"
				+ "\n" + webAddress;
		Dialogues.showAlertDialogue(exception, recoveryMessage);
	}
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:23,代码来源:Main.java

示例6: jMenuHelpGuide_actionPerformed

import java.awt.Desktop; //导入方法依赖的package包/类
protected void jMenuHelpGuide_actionPerformed(ActionEvent e) throws IOException, URISyntaxException {
    //Util.runBrowser(App.GUIDE_URL);
	if(Desktop.isDesktopSupported())
	{
	  Desktop.getDesktop().browse(new URI(App.GUIDE_URL));
	}
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:8,代码来源:AppFrame.java

示例7: browse

import java.awt.Desktop; //导入方法依赖的package包/类
/**
 * On systems where Desktop.getDesktop().browse() does not work for http://, creates an HTML
 * page which redirects to the given URI and calls Desktop.browse() with this file through the
 * file:// url which seems to work better, at least for KDE.
 */
public static void browse(URI uri) throws IOException {
	if (Desktop.isDesktopSupported()) {
		try {
			Desktop.getDesktop().browse(uri);
		} catch (IOException e) {
			File tempFile = File.createTempFile("rmredirect", ".html");
			tempFile.deleteOnExit();
			FileWriter out = new FileWriter(tempFile);
			try {
				out.write(String.format(
						"<!DOCTYPE html>\n"
								+ "<html><meta http-equiv=\"refresh\" content=\"0; URL=%s\"><body>You are redirected to %s</body></html>",
						uri.toString(), uri.toString()));
			} finally {
				out.close();
			}
			Desktop.getDesktop().browse(tempFile.toURI());
		} catch (UnsupportedOperationException e1) {
			throw new IOException(e1);
		}
	} else {
		LOGGER.log(Level.SEVERE, "Failed to open web page in browser, browsing is not supported on this platform.");
		SwingTools.showVerySimpleErrorMessage("url_handler.unsupported", uri.toString());
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:32,代码来源:RMUrlHandler.java

示例8: openWebPage

import java.awt.Desktop; //导入方法依赖的package包/类
/**
  * Apre la pagina web indicata dal parametro uri nel browser predefinito
  * @param uri pagina web da aprire.
  * @throws Exception se l'uri non è valido.
  */
 private static void openWebPage(URI uri)
 					throws Exception {
 	Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
 	
 	if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
desktop.browse(uri);
 	}
 }
 
开发者ID:steppp,项目名称:Breadth-First-Search,代码行数:14,代码来源:MainController.java

示例9: handleEvent

import java.awt.Desktop; //导入方法依赖的package包/类
@Override public void handleEvent(Event event) {
    HTMLAnchorElement anchorElement = (HTMLAnchorElement) event.getCurrentTarget();
    String href = anchorElement.getHref();

    if (Desktop.isDesktopSupported()) {
        openLinkInSystemBrowser(href);
    } else {
        LOGGER.warning("OS does not support desktop operations like browsing. Cannot open link '{" + href + "}'.");
    }

    event.preventDefault();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:13,代码来源:HyperlinkRedirectListener.java

示例10: showInBrowser

import java.awt.Desktop; //导入方法依赖的package包/类
private void showInBrowser(String url) {
	if (!Desktop.isDesktopSupported()) {
		log.warning("No Desktop support, can't show help from " + url);
		return;
	}
	try {
		Desktop.getDesktop().browse(new URI(url));
	} catch (Exception ex) {
		log.warning("Couldn't show " + url + "; caught " + ex);
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:12,代码来源:AEViewerAboutDialog.java

示例11: openHarComapareInBrowser

import java.awt.Desktop; //导入方法依赖的package包/类
public void openHarComapareInBrowser() {
    String add = server().url() + "/dashboard/harCompare/home.html";
    if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
        try {
            Desktop.getDesktop().browse(new URL(add).toURI());
        } catch (URISyntaxException | IOException ex) {
            Logger.getLogger(DashBoardManager.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:11,代码来源:DashBoardManager.java

示例12: openInBrowser

import java.awt.Desktop; //导入方法依赖的package包/类
@Override
public void openInBrowser(URI uri) {
  Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
  if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
      try {
        desktop.browse(uri);
      } catch (IOException e) {
      }
  }
}
 
开发者ID:stefanhaustein,项目名称:nativehtml,代码行数:11,代码来源:SwingPlatform.java

示例13: runBrowser

import java.awt.Desktop; //导入方法依赖的package包/类
/**
 * Calls computer's default browser to open a URL. If unable to find a default,
 * or Java's awt.Desktop library is unsupported for a machine, the user will be
 * asked to find their preferred browser executable in their files the first time
 * they open a browswer. After finding an executable, the browser is launched.
 * @param url String
 */
public static void runBrowser(String url) {
    //if (!checkBrowser())
    //    return;
    //String commandLine = MimeTypesList.getAppList().getBrowserExec()+" "+url;
    //Util.debug("Run: " + commandLine);
    String commandLine = "";
    try {
        /*DEBUG*/
        //Runtime.getRuntime().exec(commandLine);
    if(Desktop.isDesktopSupported()){
            Desktop.getDesktop().browse(new URI(url));
        }
        else {
            if (checkBrowser()){            //Original code just moved here
                commandLine = MimeTypesList.getAppList().getBrowserExec()+" "+url;
                Util.debug("Run: " + commandLine);
                Runtime.getRuntime().exec(commandLine);
            }
        }
    }
    catch (Exception ex) {
        new ExceptionDialog(ex, "Failed to run an external web-browser application with commandline<br><code>"
                +commandLine+"</code>", "Check the application path and command line parameters " +
                "(File-&gt;Preferences-&gt;Resource types).");
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:34,代码来源:Util.java

示例14: showInBrowser

import java.awt.Desktop; //导入方法依赖的package包/类
private void showInBrowser(String url) {
    if (!Desktop.isDesktopSupported()) {
        log.warning("No Desktop support, can't show help from " + url);
        return;
    }
    try {
        Desktop.getDesktop().browse(new URI(url));
    } catch (IOException | URISyntaxException ex) {
        log.warning("Couldn't show " + url + "; caught " + ex);
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:12,代码来源:EventFilter.java

示例15: openLink

import java.awt.Desktop; //导入方法依赖的package包/类
@FXML
void openLink(ActionEvent event) {
    if (Desktop.isDesktopSupported()) {
        try {
            Desktop d = Desktop.getDesktop();
            d.browse(new URI("https://github.com/dainesch/HueSense"));
        } catch (IOException | URISyntaxException ex) {
            LOG.error("Error opening url", ex);
        }
    }
}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:12,代码来源:AboutPresenter.java


注:本文中的java.awt.Desktop.isDesktopSupported方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。