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


Java Desktop.open方法代码示例

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


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

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

示例2: doShowFolderInDesktop

import java.awt.Desktop; //导入方法依赖的package包/类
public void doShowFolderInDesktop() {
    if (!Desktop.isDesktopSupported()) {
        log.warning("Sorry, desktop operations are not supported");
        return;
    }
    try {
        Desktop desktop = Desktop.getDesktop();
        File f = new File(lastFileName);
        if (f.exists()) {
            desktop.open(f.getParentFile());
        }
    } catch (Exception e) {
        log.warning(e.toString());
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:16,代码来源:AbstractAviWriter.java

示例3: runJavac

import java.awt.Desktop; //导入方法依赖的package包/类
private void runJavac() throws IOException, InterruptedException {
		//String batchFile = "C:\\Users\\inhoj\\Desktop\\eclipse\\workspace\\The Coder\\run.bat";
		String batchFile = "C:\\The Coder\\run.bat";
		/*String[] commands = {"cmd.exe", "/c", "C:\\Users\\inhoj\\Desktop\\eclipse\\workspace\\The Coder\\run.bat"};
		Process proc = Runtime.getRuntime().exec(commands);*/
		
		/*Display display = new Display();
		Program.launch(batchFile);
		display.dispose();*/
		
		//File bfile = new File("C:\\Users\\inhoj\\Desktop\\eclipse\\workspace\\The Coder\\run.bat");
		File bfile = new File("C:\\The Coder\\run.bat");
		
		
		Desktop desk = Desktop.getDesktop();
		long start = System.currentTimeMillis(); //시작시각
		synchronized (desk) {
			desk.open(bfile);		
			Thread.sleep(2000);
		}
		//Add kill CMD process code after 2s
		Runtime rt = Runtime.getRuntime();
		rt.exec("taskkill " +"/IM CMD.EXE");
/*	
		long end = System.currentTimeMillis(); //끝나는 시각
		
		long gap = (int)((end-start)/1000);
		
		System.out.println(gap+"초");
		if(gap>3) System.exit(0);*/
		 //Desktop.getDesktop().open(bfile);
		 //Desktop.getDesktop().wait(2000);
		/*Runtime rt = Runtime.getRuntime();
		String batFile = "C:\\Users\\inhoj\\Desktop\\eclipse\\workspace\\The Coder\\run.bat";
		Process proc;
		
		try {
			proc = rt.exec(batFile);
			proc.waitFor();
		} catch(Exception e) {
			e.printStackTrace();
		}*/
		//Thread.sleep(1500);
	}
 
开发者ID:INSUPARK83,项目名称:way_learning,代码行数:45,代码来源:Compute.java


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