Mastering JavaFX 10
上QQ阅读APP看书,第一时间看更新

Setting fullscreen and other window options

There are several other options to manipulate Stage that are self-explanatory, like in the following examples:

// chapter1.StageFullScreen.java
stage.setFullScreen(true);
stage.setIconified(true);
stage.setMaxWidth(100);
//...

The only unusual thing about this API is the extra fullscreen options—you can set up a warning message and key combination to exit fullscreen using the following methods:

 primaryStage.setFullScreenExitHint("Exit code is Ctrl+B");
primaryStage.setFullScreenExitKeyCombination(KeyCombination.valueOf("Ctrl+B"));

Note the convenient KeyCombination class, which can parse names of shortcuts. If you prefer more strict methods, you can use KeyCodeCombination instead:

KeyCodeCombination kc = new KeyCodeCombination(KeyCode.B, KeyCombination.CONTROL_DOWN);