{"id":2282,"date":"2013-01-02T09:31:50","date_gmt":"2013-01-02T08:31:50","guid":{"rendered":"http:\/\/sahits.ch\/blog\/?p=2282"},"modified":"2013-01-02T09:32:54","modified_gmt":"2013-01-02T08:32:54","slug":"javafx-fullscreen-toggle","status":"publish","type":"post","link":"http:\/\/sahits.ch\/blog\/blog\/2013\/01\/02\/javafx-fullscreen-toggle\/","title":{"rendered":"JavaFX: Fullscreen toggle"},"content":{"rendered":"<p>One of the things, that I could never get to work with a Swing application is the full screen mode on a Linux (Ubuntu, Mint) machine. There was always a panel (menu bar) that would be in the way and hide part of the application. Furthermore it is inherently more difficult to handle the proper layout. Therefore I did a quick test with JavaFX to see if these issues have been overcome.<\/p>\n<p><!--more-->And they have. I reused the example with the scalable ImageViewPane and added a mouse click handler on the stage which simply toggles between full screen and windowed mode.<\/p>\n<pre class=\"brush:java\">    private boolean fullsreen = false;\r\n\r\n    @Override\r\n    public void start(final Stage primaryStage) {\r\n        try {\r\n            Image img = new Image( getClass().getResource(\"kajak4_small.png\").openStream());\r\n            ImageViewPane imageViewPane = new ImageViewPane(new ImageView(img));\r\n\r\n            StackPane root = new StackPane();\r\n            root.getChildren().add(imageViewPane);\r\n\r\n            root.setOnMousePressed(new EventHandler&lt;MouseEvent&gt;(){\r\n                @Override\r\n                public void handle(MouseEvent t) {\r\n                    primaryStage.setFullScreen(!fullsreen);\r\n                    fullsreen = !fullsreen;\r\n                }\r\n            });\r\n\r\n            Scene scene = new Scene(root, 300, 250);\r\n            primaryStage.setTitle(\"FullscreenTest\");\r\n            primaryStage.setScene(scene);\r\n            primaryStage.show();\r\n        } catch (IOException ex) {\r\n            Logger.getLogger(FullscreenTest.class.getName()).log(Level.SEVERE, null, ex);\r\n        }\r\n    }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>One of the things, that I could never get to work with a Swing application is the full screen mode on a Linux (Ubuntu, Mint) machine. There was always a panel (menu bar) that would be in the way and hide part of the application. Furthermore it is inherently more difficult to handle the proper &hellip; <a href=\"http:\/\/sahits.ch\/blog\/blog\/2013\/01\/02\/javafx-fullscreen-toggle\/\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eJavaFX: Fullscreen toggle\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[138,7,6],"tags":[255,252,256],"class_list":["post-2282","post","type-post","status-publish","format-standard","hentry","category-it","category-java","category-programmieren","tag-fullscreen","tag-javafx","tag-mouse-handler"],"_links":{"self":[{"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/posts\/2282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/comments?post=2282"}],"version-history":[{"count":3,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/posts\/2282\/revisions"}],"predecessor-version":[{"id":2284,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/posts\/2282\/revisions\/2284"}],"wp:attachment":[{"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/media?parent=2282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/categories?post=2282"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/tags?post=2282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}