當前位置: 首頁>>代碼示例>>Java>>正文


Java Desktop.browse方法代碼示例

本文整理匯總了Java中java.awt.Desktop.browse方法的典型用法代碼示例。如果您正苦於以下問題:Java Desktop.browse方法的具體用法?Java Desktop.browse怎麽用?Java Desktop.browse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Desktop的用法示例。


在下文中一共展示了Desktop.browse方法的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: 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

示例3: mouseClicked

import java.awt.Desktop; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e)
{
	try
	{
		Desktop desktop = java.awt.Desktop.getDesktop();
		URI uri = new java.net.URI(href);
		desktop.browse(uri);
	}
	catch( Exception ex )
	{
		ex.printStackTrace();
		JOptionPane.showMessageDialog(null, "Unable to open link in the system browser",
			"Could not follow link", JOptionPane.ERROR_MESSAGE);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:GLink.java

示例4: mouseClicked

import java.awt.Desktop; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e)
{
	if( e.getSource() == preamble )
	{
		try
		{
			Desktop desktop = java.awt.Desktop.getDesktop();
			URI uri = new java.net.URI(CANVAS_SIGNUP_URL);
			desktop.browse(uri);
		}
		catch( Exception ex )
		{
			ex.printStackTrace();
			JOptionPane.showMessageDialog(null, "Unable to open link in the system browser",
				"Could not follow link", JOptionPane.ERROR_MESSAGE);
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:20,代碼來源:CanvasSettingsPanel.java

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

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

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

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

import java.awt.Desktop; //導入方法依賴的package包/類
private void jLabel8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel8MouseClicked
    try {                                     
        String s = "https://github.com/danger229/ButtonSwap3dsMaker/issues";
        Desktop desktop = Desktop.getDesktop();
        desktop.browse(URI.create(s));
    } catch (IOException ex) {}
}
 
開發者ID:danger229,項目名稱:ButtonSwap3dsMaker,代碼行數:8,代碼來源:ButtonSwapHelper.java

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

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

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

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

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

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


注:本文中的java.awt.Desktop.browse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。