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