Proper way to start the main app flow (window resizing issue)

113 views
Skip to first unread message

Marcin Rosiński

unread,
Jan 20, 2015, 3:51:23 AM1/20/15
to dataf...@googlegroups.com
Hi folks!

First of all, I must say that I'm really excited about DataFX framework, it's really helpful for me when developing current application.

But there is one small thing that looms large in my mind. When resizing or maximalizing window size, there is an additional empty space around, but content stays at the same size. Here is how I start main flow:

Flow flow = new Flow(MainWindowCtrl.class);

try {
    flow.startInStage(getPrimaryStage());
} catch (FlowException e) {
    throw new RuntimeException("Cannot start MainWindow flow.", e);
}

Initially I thought that view was designed incorrectly, but in the Scene Builder it scales properly. Moreover, when starting app in a "classic JavaFX way", it also works properly:

try {
         FXMLLoader loader = new FXMLLoader();
    loader.setLocation(PainGui.class.getResource("/view/main/MainWindow.fxml"));
    BorderPane rootWindow = (BorderPane) loader.load();

    Scene scene = new Scene(rootWindow);
    primaryStage.setScene(scene);
    primaryStage.show();
} catch (IOException e) {
    throw new RuntimeException("Cannot load MainWindow view.", e);
}

Of course in that case all DataFX features and flows won't work, but still, window content scales to its size. Please, let me know how should I start main window flow. DataFX tutorials looks outdated...

Regards,
Marcin

Hendrik Ebbers

unread,
Jan 20, 2015, 3:58:24 AM1/20/15
to dataf...@googlegroups.com
Hi & thanks for the feedback,

When starting a flow a FlowContainer will be generated that manages and holds the flow. To do so the container creates a wrapper (a JavaFX Node) around the flow. In this wrapper the current view is added. The default implementation (DefaultFlowContainer) uses a StackPane internally as a Wrapper around the flow. The stack pane layouts its children to the preferred size by default. Therefore your content won't grow over the default size.

There are 2 different ways how you can solve this problem:
- Define a Double.Max_Value size as the preferred size for your views
- create your own FlowContainer. To do so you need to implement the FlowContainer interface like it is done for the DefaultFlowContainer

If you have found a working solution it would be great if you can post it here :)

Hendrik

Marcin Rosiński

unread,
Jan 20, 2015, 4:39:07 AM1/20/15
to dataf...@googlegroups.com
Thank you! You've helped me a lot in just a few minutes. :)

The simpliest solutions are the best ones. As you suggested, I've changed dimensions of the main view in the FXML file:
1) preferred width & height remained the same - they specify default window size after running app;
2) max width & height were set to Double.MAX_VALUE - this lets content to grow up when enlarging window size;
3) min width & height were removed (or set to USE_COMPUTED_SIZE in the Scene Builder) - this lets content to fit window properly when reducing window size;

Additionally, I set primary stage's minWidth & minHeight in Java, so the workspace can't be reduced below usable size.

Thanks a lot again!
Marcin
Reply all
Reply to author
Forward
0 new messages