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


Java Desktop.isSupported方法代码示例

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


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

示例1: onClick

import java.awt.Desktop; //导入方法依赖的package包/类
@Override
public void onClick(ActionEvent arg0)
{
    try
    {
        URI     v_URI     = URI.create(AppMain.$SourceCode);
        Desktop v_Desktop = Desktop.getDesktop();
        
        // 判断系统桌面是否支持要执行的功能
        if ( v_Desktop.isSupported(Desktop.Action.BROWSE) )
        {
            // 获取系统默认浏览器打开链接
            v_Desktop.browse(v_URI);
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:HY-ZhengWei,项目名称:HBaseClient,代码行数:21,代码来源:MenuSupportAction.java

示例2: openInBrowser

import java.awt.Desktop; //导入方法依赖的package包/类
/**
 * If possible this method opens the default browser to the specified web
 * page. If not it notifies the user of webpage's url so that they may
 * access it manually.
 *
 * @param message Error message to display
 * @param uri
 */
public static void openInBrowser(String message, URI uri) {
    try {
        java.util.logging.Logger.getLogger(Help.class.getName()).log(Level.INFO, "Opening url {0}", uri);
        Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
        if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
            desktop.browse(uri);
        } else {
            throw new UnsupportedOperationException("Desktop Api Not supported in this System");
        }
    } catch (Exception e) {
        java.util.logging.Logger.getLogger(Help.class.getName()).log(Level.WARNING, null, e);
        // Copy URL to the clipboard so the user can paste it into their browser
        Utils.copyTextToClipboard(uri.toString());
        // Notify the user of the failure
        JOptionPane.showMessageDialog(null, message + "\n"
                + "The URL has been copied to your clipboard, simply paste into your browser to access.\n"
                + "Webpage: " + uri);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:28,代码来源:Help.java

示例3: connectToServerUsingProtocol

import java.awt.Desktop; //导入方法依赖的package包/类
/**
 * Connects to the given server (IP and Port) using an empty (no) password.
 * Other than
 * {@link GTAController#connectToServer(String)} and
 * {@link GTAController#connectToServer(String, String)}, this method uses the
 * <code>samp://</code> protocol to connect to make the samp launcher connect to
 * the server.
 *
 * @param ipAndPort
 *            the server to connect to
 * @return true if it was most likely successful
 */
private static boolean connectToServerUsingProtocol(final String ipAndPort) {
	if (!OSUtility.isWindows()) {
		return false;
	}

	try {
		Logging.info("Connecting using protocol.");
		final Desktop desktop = Desktop.getDesktop();

		if (desktop.isSupported(Action.BROWSE)) {
			desktop.browse(new URI("samp://" + ipAndPort));
			return true;
		}
	}
	catch (final IOException | URISyntaxException exception) {
		Logging.warn("Error connecting to server.", exception);
	}

	return false;
}
 
开发者ID:Bios-Marcel,项目名称:ServerBrowser,代码行数:33,代码来源:GTAController.java

示例4: createExternalBrowser

import java.awt.Desktop; //导入方法依赖的package包/类
private HtmlBrowserComponent createExternalBrowser() {
    Factory browser = IDESettings.getExternalWWWBrowser();
    if (browser == null) {
        Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
        if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
            browser = new DesktopBrowser(desktop);
        } else {
            //external browser is not available, fallback to swingbrowser
            browser = new SwingBrowser();
        }
    }
    return new HtmlBrowserComponent(browser, true, true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:NbURLDisplayer.java

示例5: openURL

import java.awt.Desktop; //导入方法依赖的package包/类
/**
 * Launch the given URL in the system browser
 * @param url the URL to launch
 */
public static void openURL(String url) {
	Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
	if (desktop != null && desktop.isSupported(Action.BROWSE)) {
		try {
			desktop.browse(new URI(url));
		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
		}
	} else {
		fallbackURL(url);
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:17,代码来源:BrowserLauncher.java

示例6: isBrowsingSupported

import java.awt.Desktop; //导入方法依赖的package包/类
private static boolean isBrowsingSupported()
{
	if( !Desktop.isDesktopSupported() )
	{
		return false;
	}
	final Desktop desktop = java.awt.Desktop.getDesktop();
	if( desktop.isSupported(Desktop.Action.BROWSE) )
	{
		return true;
	}
	return false;
}
 
开发者ID:equella,项目名称:Equella,代码行数:14,代码来源:GLink.java

示例7: openWebpage

import java.awt.Desktop; //导入方法依赖的package包/类
private void openWebpage(URI uri) {
    Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
    if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
        try {
            desktop.browse(uri);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:QuantumSoundings,项目名称:BassNES,代码行数:11,代码来源:MainUI.java

示例8: jMenuItem59ActionPerformed

import java.awt.Desktop; //导入方法依赖的package包/类
private void jMenuItem59ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem59ActionPerformed
    int sel = jTabbedPane1.getSelectedIndex();
    RSyntaxTextArea textPane = (RSyntaxTextArea) Editor.get(sel).getTextPane();
    String comp = textPane.getSelectedText();; 
    String url = "https://www.google.com.ng/search?site=&source=hp&q=" + comp;
    try
    {
        URI uri = new URL(url).toURI();
        Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
        if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE))
            desktop.browse(uri);
    }
catch (Exception e)
    {}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:16,代码来源:Main.java

示例9: googlesearch

import java.awt.Desktop; //导入方法依赖的package包/类
public static void googlesearch(){
    String searchquery = searchbox.getText();
    searchquery = searchquery.replace(' ', '-');
    String squery = squerry.getText();
    squery = squery.replace(' ', '-');
    if ("".equals(searchquery)){
        searchquery = squery ;
    } else {}
    String url = "https://www.google.com.ng/search?site=&source=hp&q=" + searchquery ;
    try
        {
            URI uri = new URL(url).toURI();
            Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE))
                desktop.browse(uri);
        }
    catch (URISyntaxException | IOException e)
        {
            JOptionPane.showMessageDialog(null, e.getMessage());
            // Copy URL to the clipboard so the user can paste it into their browser
            StringSelection stringSelection = new StringSelection(searchquery);
            Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
            clpbrd.setContents(stringSelection, null);
            // Notify the user of the failure
            System.out.println("This program just tried to open a webpage." + "\n"
                + "The URL has been copied to your clipboard, simply paste into your browser to accessWebpage: " + url);
        }
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:29,代码来源:GoogleSearch.java

示例10: wikisearch

import java.awt.Desktop; //导入方法依赖的package包/类
public static void wikisearch(){
    String searchqueryw = searchbox.getText();
    searchqueryw = searchqueryw.replace(' ', '-');
    String squeryw = squerry.getText();
    squeryw = squeryw.replace(' ', '-');
    if ("".equals(searchqueryw)){
        searchqueryw = squeryw ;
    } else {}
    String url = "https://www.wikipedia.org/wiki/" + searchqueryw ;
    try
        {
            URI uri = new URL(url).toURI();
            Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE))
                desktop.browse(uri);
        }
    catch (URISyntaxException | IOException e)
        {
            /*
             *  I know this is bad practice 
             *  but we don't want to do anything clever for a specific error
             */
            JOptionPane.showMessageDialog(null, e.getMessage());

            // Copy URL to the clipboard so the user can paste it into their browser
            StringSelection stringSelection = new StringSelection(url);
            Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
            clpbrd.setContents(stringSelection, null);
            // Notify the user of the failure
            System.out.println("This program just tried to open a webpage." + "\n"
                + "The URL has been copied to your clipboard, simply paste into your browser to accessWebpage: " + url);
        }
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:34,代码来源:WikiSearch.java

示例11: bingsearch

import java.awt.Desktop; //导入方法依赖的package包/类
public static void bingsearch(){
    String searchqueryb = searchbox.getText();
    String squeryb = squerry.getText();
    searchqueryb = searchqueryb.replace(' ', '-');
    squeryb = squeryb.replace(' ', '-');
    if ("".equals(searchqueryb)){
        searchqueryb = squeryb ;
    } else {}
    String url = "https://www.bing.com/search?q=" + searchqueryb ;
    try
        {
            URI uri = new URL(url).toURI();
            Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE))
                desktop.browse(uri);
        }
    catch (URISyntaxException | IOException e)
        {
            /*
             *  I know this is bad practice 
             *  but we don't want to do anything clever for a specific error
             */
            JOptionPane.showMessageDialog(null, e.getMessage());
            // Copy URL to the clipboard so the user can paste it into their browser
            StringSelection stringSelection = new StringSelection(searchqueryb);
            Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
            clpbrd.setContents(stringSelection, null);
            // Notify the user of the failure
            System.out.println("This program just tried to open a webpage." + "\n"
                + "The URL has been copied to your clipboard, simply paste into your browser to accessWebpage: " + url);
        }
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:33,代码来源:BingSearch.java

示例12: openWebpage

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

示例13: 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

示例14: openWebsite

import java.awt.Desktop; //导入方法依赖的package包/类
/**
 * Opens a Website in the Browser
 *
 * @param uri - Target URI
 */
public static void openWebsite(URI uri) {
	Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;

	if(desktop == null)
		return;

	if(desktop.isSupported(Desktop.Action.BROWSE)) {
		try {
			desktop.browse(uri);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:Petschko,项目名称:Java-RPG-Maker-MV-Decrypter,代码行数:20,代码来源:Functions.java

示例15: openBrowse

import java.awt.Desktop; //导入方法依赖的package包/类
private void openBrowse() {
  try {
    Desktop desktop = Desktop.getDesktop();
    if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {
      URI uri = new URI("http://" + (HttpDownServer.isDev() ? "localhost" : "127.0.0.1") + ":"
          + HttpDownServer.VIEW_SERVER_PORT);
      desktop.browse(uri);
    }
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
 
开发者ID:monkeyWie,项目名称:proxyee-down,代码行数:13,代码来源:DownTray.java


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