Swing/Desktop のバックアップソース(No.3)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- バックアップ を表示
- Swing/Desktop へ行く。
- 1 (2007-02-19 (月) 16:02:04)
- 2 (2007-02-20 (火) 16:39:54)
- 3 (2007-07-26 (木) 17:09:54)
- 4 (2008-02-19 (火) 15:15:17)
- 5 (2012-01-27 (金) 17:18:20)
- 6 (2013-09-15 (日) 00:18:32)
- 7 (2014-12-30 (火) 15:32:42)
- 8 (2016-04-15 (金) 12:43:38)
- 9 (2017-08-02 (水) 15:31:35)
- 10 (2018-08-03 (金) 14:08:29)
- 11 (2018-11-01 (木) 21:40:51)
- 12 (2020-11-02 (月) 11:25:42)
- 13 (2022-09-27 (火) 17:11:30)
TITLE:Desktopでブラウザを起動 #navi(../) *Desktopでブラウザを起動 [#jdc5207e] >編集者:[[Terai Atsuhiro>terai]]~ 作成日:2007-02-19~ 更新日:&lastmod; #contents **概要 [#s91ea8f3] JDK 6 で導入されたDesktopを使ってブラウザを起動します。 #screenshot **サンプルコード [#ndf80e33] #code{{ public void mousePressed(MouseEvent e) { if(!Desktop.isDesktopSupported()) return; try{ Desktop.getDesktop().browse(new URI(href)); }catch(IOException ioe) { ioe.printStackTrace(); }catch(URISyntaxException use) { use.printStackTrace(); } } }} //-&jnlp; -&jar; -&zip; **解説 [#e351d712] Desktopを使用することで、ブラウザのほかにも、メーラーや拡張子に関連付けられたデフォルトのアプリケーションを起動することが出来るようになります。 このため、OS毎に、Runtime.getRuntime().exec(String[])でアプリケーションを切り替えて実行する必要がなくなります。 **参考リンク [#z1b70371] -[[Using the Desktop API in Java SE 6 (Mustang)>http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/desktop_api/]] -[[Browserを起動>Swing/BrowserLauncher]] **コメント [#g46c8031] #comment