11package nl .ou .testar .jfx ;
22
33import javafx .scene .Parent ;
4+ import javafx .scene .Scene ;
45import javafx .scene .layout .AnchorPane ;
56import javafx .scene .layout .BorderPane ;
67import javafx .scene .layout .Pane ;
78import javafx .scene .layout .VBox ;
89import javafx .scene .shape .Rectangle ;
10+ import javafx .stage .Stage ;
11+ import javafx .stage .Window ;
912import nl .ou .testar .jfx .core .NavigationController ;
1013import nl .ou .testar .jfx .core .NavigationDelegate ;
1114import nl .ou .testar .jfx .core .ViewController ;
@@ -31,6 +34,8 @@ enum Mode {
3134 private SettingsController settingsController ;
3235 private MiscController miscController ;
3336
37+ private Stage stage = null ;
38+
3439 public DashboardController getDashboardController () {
3540 return dashboardController ;
3641 }
@@ -44,6 +49,7 @@ public MainController(Settings settings, String settingsPath) {
4449 }
4550
4651 private void setupMode (Parent view , Mode mode ) {
52+
4753 if (mode != this .mode ) {
4854// final Label titleLabel = (Label) view.lookup("#titleLabel");
4955// final Button btnBack = (Button) view.lookup("#btnBack");
@@ -73,9 +79,17 @@ public void onViewControllerActivated(ViewController viewController, Parent view
7379 AnchorPane .setTopAnchor (view , 0.0 );
7480 AnchorPane .setRightAnchor (view , 0.0 );
7581 AnchorPane .setBottomAnchor (view , 0.0 );
76- // btnBack.setVisible(navigationController.isBackAvailable());
77- // contentPane.getChildren().removeAll();
78- // contentPane.getChildren().add(view);
82+
83+ if (stage != null ) {
84+ double width = stage .getWidth ();
85+ double height = stage .getHeight ();
86+
87+ view .setVisible (false );
88+ stage .sizeToScene ();
89+ stage .setWidth (Math .max (width , stage .getWidth ()));
90+ stage .setHeight (Math .max (height , stage .getHeight ()));
91+ view .setVisible (true );
92+ }
7993 }
8094 });
8195
@@ -95,6 +109,7 @@ public void viewDidLoad(Parent view) {
95109
96110 btnHome .setOnAction (event -> {
97111 setupMode (view , Mode .HOME );
112+
98113 });
99114
100115 btnSettings .setOnAction (event -> {
@@ -107,4 +122,9 @@ public void viewDidLoad(Parent view) {
107122
108123 setupMode (view , Mode .HOME );
109124 }
125+
126+ @ Override
127+ public void viewDidAppear (Parent view ) {
128+ stage = (Stage ) view .getScene ().getWindow ();
129+ }
110130}
0 commit comments