當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。