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


Java Desktop类代码示例

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


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

示例1: updaterUpdateAvailable

import java.awt.Desktop; //导入依赖的package包/类
@Override
public final void updaterUpdateAvailable(final String localVersion, final String remoteVersion) {
	final String link = "https://github.com/" + GithubUpdater.UPDATER_GITHUB_USERNAME + "/" + GithubUpdater.UPDATER_GITHUB_REPO + "/releases/latest";
	if(JOptionPane.showConfirmDialog(this, "<html>An update is available : v" + remoteVersion + " !<br/>" + "Would you like to visit " + link + " to download it ?</html>", Constants.APP_NAME, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
		try {
			if(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
				Desktop.getDesktop().browse(new URI(link));
			}
		}
		catch(final Exception ex) {
			ex.printStackTrace(guiPrintStream);
			ex.printStackTrace();
			JOptionPane.showMessageDialog(ProjectsFrame.this, String.format(Constants.GUI_DIALOG_ERROR_MESSAGE, ex.getMessage()), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE);
		}
	}
}
 
开发者ID:Skyost,项目名称:SkyDocs,代码行数:17,代码来源:ProjectsFrame.java

示例2: actionPerformed

import java.awt.Desktop; //导入依赖的package包/类
@Override
protected void actionPerformed(GuiButton clickedButton) throws IOException {
	if (clickedButton.id == 0) {
		try {
			String link = "https://github.com/Moudoux/EMC-Installer/releases";
			if (clientInfo.get("updateLinkOverride").getAsBoolean()) {
				link = clientInfo.get("website").getAsString();
			}
			Desktop.getDesktop().browse(new URL(link).toURI());
		} catch (Exception e) {
			;
		}
		Minecraft.getMinecraft().shutdown();
	}
	Minecraft.getMinecraft().displayGuiScreen(null);
	super.actionPerformed(clickedButton);
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:18,代码来源:GuiUpdateLoader.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: start

import java.awt.Desktop; //导入依赖的package包/类
@Override public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Simple Web Server");
    BorderPane root = new BorderPane();
    TextArea area = new TextArea();
    root.setCenter(area);
    ToolBar bar = new ToolBar();
    Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true);
    openInBrowser.setOnAction((event) -> {
        try {
            Desktop.getDesktop().browse(URI.create(webRoot));
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    Button changeRoot = FXUIUtils.createButton("fldr_closed", "Change Web Root", true);
    changeRoot.setOnAction((event) -> {
        DirectoryChooser chooser = new DirectoryChooser();
        File showDialog = chooser.showDialog(primaryStage);
        if (showDialog != null)
            server.setRoot(showDialog);
    });
    bar.getItems().add(openInBrowser);
    bar.getItems().add(changeRoot);
    root.setTop(bar);
    System.setOut(new PrintStream(new Console(area)));
    System.setErr(new PrintStream(new Console(area)));
    area.setEditable(false);
    primaryStage.setScene(new Scene(root));
    primaryStage.setOnShown((e) -> startServer(getParameters().getRaw()));
    primaryStage.show();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:32,代码来源:SimpleWebServer.java

示例5: onActionClickAliasHyperlink

import java.awt.Desktop; //导入依赖的package包/类
public void onActionClickAliasHyperlink() {
    LoggerFacade.getDefault().debug(this.getClass(), "On action click [Alias] Hyperlink"); // NOI18N
    
    if (
            Desktop.isDesktopSupported()
            && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)
    ) {
        try {
            final URL url = new URL(link.getUrl());
            Desktop.getDesktop().browse(url.toURI());
        } catch (IOException | URISyntaxException ex) {
            LoggerFacade.getDefault().error(this.getClass(), "Can't open url: " + link.getUrl(), ex); // NOI18N
        }
    } else {
        LoggerFacade.getDefault().warn(this.getClass(), "Desktop.isDesktopSupported() isn't supported");
    }
}
 
开发者ID:Naoghuman,项目名称:ABC-List,代码行数:18,代码来源:LinkPanePresenter.java

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

示例7: browse

import java.awt.Desktop; //导入依赖的package包/类
/**
 * Browse the given URL
 *
 * @param url url
 * @param name title
 */
public static void browse(final URL url, final String name) {
	if (Desktop.isDesktopSupported()) {
		try {
			// need this strange code, because the URL.toURI() method have
			// some trouble dealing with UTF-8 encoding sometimes
			final URI uri = new URI(url.getProtocol(), url.getAuthority(), url.getPath(), url.getQuery(), url.getRef());
			Desktop.getDesktop().browse(uri);
		} catch (final Exception e) {
			LOGGER.error(e.getMessage(), e);
			JOptionPane.showMessageDialog(null, Resources.getLabel("error.open.url", name));
		}
	} else {
		JOptionPane.showMessageDialog(null, Resources.getLabel("error.open.url", name));
	}
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:22,代码来源:Util.java

示例8: jButtonIniciarActionPerformed

import java.awt.Desktop; //导入依赖的package包/类
private void jButtonIniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonIniciarActionPerformed
    try {      
        // Consumiendo web service
        String json = iniciarServidor();
        user = new Gson().fromJson(json, Pc.class);
        System.out.println("Recibido: " + user);
        
        jLabel1.setForeground(Color.green);
        Desktop.getDesktop().browse(new URI("http://" + ip + ":" + user.getPuertoPHP() + "/phpmyadmin"));
        url.setText("http://" + ip + ":" + user.getPuertoPHP() + "/phpmyadmin");
        jlabelSQL.setText("PuertoSQL: " + user.getPuertoSQL());
        this.setTitle("App [ID:" + user.getId() + "]");

    } catch (IOException | URISyntaxException ex) {
        Logger.getLogger(VentanaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:AmauryOrtega,项目名称:Sem-Update,代码行数:18,代码来源:VentanaPrincipal.java

示例9: openExplorer

import java.awt.Desktop; //导入依赖的package包/类
/**
 * Open an Explorer with the given Path
 *
 * @param directoryPath - Path to open
 * @return Open-Explorer ActionListener
 */
static ActionListener openExplorer(String directoryPath) {
	return e -> {
		Desktop desktop = Desktop.getDesktop();

		try {
			desktop.open(new java.io.File(File.ensureDSonEndOfPath(directoryPath)).getAbsoluteFile());
		} catch(Exception ex) {
			ex.printStackTrace();
			ErrorWindow errorWindow = new ErrorWindow(
					"Unable to open the File-Explorer with the Directory: " + directoryPath,
					ErrorWindow.ERROR_LEVEL_ERROR,
					false
			);

			errorWindow.show();
		}
	};
}
 
开发者ID:Petschko,项目名称:Java-RPG-Maker-MV-Decrypter,代码行数:25,代码来源:GUI_ActionListener.java

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

示例11: 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;
        try {
            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(url.toURI());
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:ContributorsTable.java

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

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

示例14: standardOpen

import java.awt.Desktop; //导入依赖的package包/类
public void standardOpen()
{
	AccessController.doPrivileged(new PrivilegedAction<Object>()
	{
		@Override
		public Object run()
		{
			try
			{
				debug("using Desktop.open");
				Desktop.getDesktop().open(tempFile);
			}
			catch( Exception io )
			{
				logException("Error opening file", io);
			}
			return null;
		}
	}, openPermissionContext);
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:InPlaceEditAppletLauncher.java

示例15: openDESKTOP

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

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

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

            Desktop.getDesktop().open(file);

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


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