2013-11-25 76 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