2013-11-25 80 views
0

請告訴我如何以編程方式更改Mac OS X中的桌面背景? 我發現,但對於Windows https://stackoverflow.com/a/12212368/2838676更改桌面背景mac os x

+1

看一看[這](http://stackoverflow.com/questions/19779980/is - 可能的改變桌面背景與java的不同操作)或[這個](http://stackoverflow.com/questions/6199907/change-desktop-background-of- MAC-系統正-使用的Java本機訪問) –

回答

1
public void setWallpaper(File file) 
throws Exception { 
    String as[] = { 
      "osascript", 
      "-e", "tell application \"Finder\"", 
      "-e", "set desktop picture to POSIX file \"" + file.getAbsolutePath() + "\"", 
      "-e", "end tell" 
    }; 
    Runtime runtime = Runtime.getRuntime(); 
    Process process; 
    process = runtime.exec(as); 
} 

現金

https://stackoverflow.com/a/5007344/1401250

https://sourceforge.net/p/jawc-wallpaperc/code/HEAD/tree/trunk/Jawc/src/it/jwallpaper/platform/impl/MacPlatform.java#l38