22
33import javafx .scene .Parent ;
44import javafx .scene .layout .AnchorPane ;
5+ import javafx .stage .Stage ;
56import nl .ou .testar .jfx .core .NavigationController ;
67import nl .ou .testar .jfx .core .NavigationDelegate ;
78import nl .ou .testar .jfx .core .ViewController ;
@@ -25,6 +26,8 @@ enum Mode {
2526 private SettingsController settingsController ;
2627 private MiscController miscController ;
2728
29+ private Stage stage = null ;
30+
2831 public DashboardController getDashboardController () {
2932 return dashboardController ;
3033 }
@@ -38,6 +41,7 @@ public MainController(Settings settings, String settingsPath) {
3841 }
3942
4043 private void setupMode (Parent view , Mode mode ) {
44+
4145 if (mode != this .mode ) {
4246// final Label titleLabel = (Label) view.lookup("#titleLabel");
4347// final Button btnBack = (Button) view.lookup("#btnBack");
@@ -67,9 +71,17 @@ public void onViewControllerActivated(ViewController viewController, Parent view
6771 AnchorPane .setTopAnchor (view , 0.0 );
6872 AnchorPane .setRightAnchor (view , 0.0 );
6973 AnchorPane .setBottomAnchor (view , 0.0 );
70- // btnBack.setVisible(navigationController.isBackAvailable());
71- // contentPane.getChildren().removeAll();
72- // contentPane.getChildren().add(view);
74+
75+ if (stage != null ) {
76+ double width = stage .getWidth ();
77+ double height = stage .getHeight ();
78+
79+ view .setVisible (false );
80+ stage .sizeToScene ();
81+ stage .setWidth (Math .max (width , stage .getWidth ()));
82+ stage .setHeight (Math .max (height , stage .getHeight ()));
83+ view .setVisible (true );
84+ }
7385 }
7486 });
7587
@@ -89,6 +101,7 @@ public void viewDidLoad(Parent view) {
89101
90102 btnHome .setOnAction (event -> {
91103 setupMode (view , Mode .HOME );
104+
92105 });
93106
94107 btnSettings .setOnAction (event -> {
@@ -101,4 +114,9 @@ public void viewDidLoad(Parent view) {
101114
102115 setupMode (view , Mode .HOME );
103116 }
117+
118+ @ Override
119+ public void viewDidAppear (Parent view ) {
120+ stage = (Stage ) view .getScene ().getWindow ();
121+ }
104122}
0 commit comments