@@ -243,16 +243,8 @@ private void initialiseUI(final Stage primaryStage) throws IOException {
243243 // Show the scene containing the root layout.
244244 final Scene mainScene = new Scene (mainPane , Color .TRANSPARENT );
245245
246- final KeyCombination keyComb = new KeyCodeCombination (KeyCode .DOWN , KeyCombination .META_DOWN );
247- mainScene .addEventFilter (KeyEvent .KEY_RELEASED , keyEvent -> {
248- LOG .debug ("Key was Pressed '{}'" , keyEvent .getCode ());
249- if (keyComb .match (keyEvent )) {
250- LOG .info ("'{}' and '{}' were pressed: iconify window" , KeyCode .META , KeyCode .DOWN );
251- primaryStage .setIconified (true );
252- keyEvent .consume ();
253- }
254- });
255-
246+ registerMinifyEventlistener (mainScene , primaryStage );
247+ registerMaximizeEventlistener (mainScene , primaryStage );
256248 // Image(Resources.getResource(RESOURCE.ICON_MAIN).toString())); // TODO use an app icon
257249
258250 primaryStage .setTitle ("KeepTime" );
@@ -274,6 +266,31 @@ public void handle(final WindowEvent event) {
274266
275267 }
276268
269+ private void registerMinifyEventlistener (final Scene mainScene , final Stage primaryStage ) {
270+ final KeyCode down = KeyCode .DOWN ;
271+ final KeyCombination keyComb = new KeyCodeCombination (down , KeyCombination .META_DOWN );
272+ mainScene .addEventFilter (KeyEvent .KEY_RELEASED , keyEvent -> {
273+ LOG .info ("Key was Pressed '{}'" , keyEvent .getCode ());
274+ if (keyComb .match (keyEvent )) {
275+ LOG .info ("'{}' and '{}' were pressed: iconify window" , KeyCode .META , down );
276+ primaryStage .setIconified (true );
277+ keyEvent .consume ();
278+ }
279+ });
280+ }
281+
282+ private void registerMaximizeEventlistener (final Scene mainScene , final Stage primaryStage ) {
283+ final KeyCombination keyComb = new KeyCodeCombination (KeyCode .UP , KeyCombination .META_DOWN );
284+ mainScene .addEventFilter (KeyEvent .KEY_RELEASED , keyEvent -> {
285+ LOG .info ("Key was Pressed '{}'" , keyEvent .getCode ());
286+ if (keyComb .match (keyEvent )) {
287+ LOG .info ("'{}' and '{}' were pressed: Miximizing window..." , KeyCode .META , KeyCode .UP );
288+ primaryStage .setIconified (false );
289+ keyEvent .consume ();
290+ }
291+ });
292+ }
293+
277294 @ Override
278295 public void stop () throws Exception {
279296 springContext .stop ();
0 commit comments