Swing/FullScreen のバックアップの現在との差分(No.3)
- バックアップ一覧
- 差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/FullScreen へ行く。
- 1 (2008-04-28 (月) 10:19:14)
- 2 (2008-04-28 (月) 18:16:22)
- 3 (2008-04-28 (月) 19:24:40)
- 4 (2008-05-24 (土) 02:17:23)
- 5 (2013-07-26 (金) 01:04:49)
- 6 (2013-09-18 (水) 20:58:37)
- 7 (2014-10-30 (木) 00:03:22)
- 8 (2015-11-20 (金) 15:20:53)
- 9 (2017-04-04 (火) 14:17:08)
- 10 (2017-05-24 (水) 17:28:52)
- 11 (2018-02-21 (水) 15:10:39)
- 12 (2020-02-20 (木) 15:10:17)
- 13 (2021-08-04 (水) 06:46:05)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:Windowのフルスクリーン化 #navi(../) *Windowのフルスクリーン化 [#kfe10736] Posted by [[terai]] at 2008-04-28 --- category: swing folder: FullScreen title: Windowのフルスクリーン化 tags: [GraphicsEnvironment, JFrame, JDialog] author: aterai pubdate: 2008-04-28T10:19:14+09:00 description: JDialogやJFrameなどを、フルスクリーン表示に切り替えます。 image: https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTNRUUD2xI/AAAAAAAAAag/G7fNPgecnss/s800/FullScreen.png --- * 概要 [#summary] `JDialog`や`JFrame`などを、フルスクリーン表示に切り替えます。 #contents #download(https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTNRUUD2xI/AAAAAAAAAag/G7fNPgecnss/s800/FullScreen.png) **概要 [#u34e48bf] JDialogやJFrameなどを、フルスクリーン表示に切り替えます。 -&jnlp; -&jar; -&zip; #screenshot **サンプルコード [#adab7743] #code{{ * サンプルコード [#sourcecode] #code(link){{ private void toggleFullScreenWindow() { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice(); if(graphicsDevice.getFullScreenWindow()==null) { dialog.dispose(); //destroy the native resources GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice(); if (Objects.isNull(graphicsDevice.getFullScreenWindow())) { dialog.dispose(); // destroy the native resources dialog.setUndecorated(true); dialog.setVisible(true); //rebuilding the native resources dialog.setVisible(true); // rebuilding the native resources graphicsDevice.setFullScreenWindow(dialog); }else{ } else { graphicsDevice.setFullScreenWindow(null); dialog.dispose(); dialog.setUndecorated(false); dialog.setVisible(true); dialog.repaint(); } requestFocusInWindow(); } }} **解説 [#f039da11] 上記のサンプルは、JDialogをフルスクリーン表示とウィンドウ表示に切り替えることが出来ます。 * 解説 [#explanation] 上記のサンプルは、`JDialog`をフルスクリーン表示とウィンドウ表示に切り替えることが出来ます。 - F11キー、ダブルクリック - KBD{F11}キー、ダブルクリック -- フルスクリーン表示、ウィンドウ表示の切り替え - ESCキー - KBD{Esc}キー -- アプリケーション終了 ---- フルスクリーン表示とウィンドウ表示を切り替える前に、タイトルバーの非表示、表示もsetUndecoratedメソッドで切り替えていますが、このメソッドを使用する前に一旦disposeしてウインドウのネイティブリソースを開放しておく必要があります。 - setUndecorated(boolean undecorated)は、ダイアログが表示されていないときにだけ呼び出すことができますが、この表示は isVisible(false)ではなく、isDisplayable()がfalseの意味なので、dialog.setVisible(false); では、 Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The dialog is ''displayable''. が発生します。 -- [[Window#dispose()>http://java.sun.com/javase/ja/6/docs/ja/api/java/awt/Window.html#dispose()]] -- [[Dialog#setUndecorated(boolean)>http://java.sun.com/javase/ja/6/docs/ja/api/java/awt/Dialog.html#setUndecorated(boolean)]] -- [[Component#isDisplayable()>http://java.sun.com/javase/ja/6/docs/ja/api/java/awt/Component.html#isDisplayable()]] - フルスクリーン表示とウィンドウ表示を切り替える前にタイトルバーの非表示、表示も`setUndecorated(...)`メソッドで切り替え -- このメソッドを使用する前に一旦`dispose`してウィンドウのネイティブリソースを開放しておく必要がある - `setUndecorated(boolean undecorated)`はウィンドウが表示されていない状態の場合のみ呼び出し可能だが、この「表示されていない」は `isVisible()`ではなく`isDisplayable()`が`false`の意味なので、`dialog.setVisible(false);`のみ実行すると`Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The dialog is ''displayable''.`が発生する -- [https://docs.oracle.com/javase/jp/8/docs/api/java/awt/Window.html#dispose-- Window (Java Platform SE 8)] -- [https://docs.oracle.com/javase/jp/8/docs/api/java/awt/Dialog.html#setUndecorated-boolean- Dialog#setUndecorated(boolean) (Java Platform SE 8)] -- [https://docs.oracle.com/javase/jp/8/docs/api/java/awt/Component.html#isDisplayable-- Component#isDisplayable() (Java Platform SE 8)] ---- Webstart(署名無し)から実行した場合、タスクバー(Windows)などを消してフルスクリーン化は出来ないようです。 * 参考リンク [#reference] - [https://docs.oracle.com/javase/tutorial/extra/fullscreen/exclusivemode.html Full-Screen Exclusive Mode (The Java™ Tutorials > Bonus > Full-Screen Exclusive Mode API)] **参考リンク [#e33e3400] -[[Lesson: Full-Screen Exclusive Mode API >http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html]] **コメント [#xe7709ed] * コメント [#comment] #comment #comment