Java FX FXML and Controllers. Best Practices?


Question

Current setup is: One main stage object--A (with GUI from FXML) and buttons. Clicking buttons on the main stage object will create objects from another class --B. B objects have different GUI FXML. In this case, is it best to create B objects each with its unique controller? Or do drive them by one controller?

1
0
11/28/2013 8:08:44 AM

Accepted Answer

I suggest to divide your GUI into some logical custom controls using the fx:root construct.

1 FXML -> 1 root/ controller

Here's the tutorial: http://docs.oracle.com/javafx/2/fxml_get_started/custom_control.htm#BABDAAHE

2
11/29/2013 9:52:51 AM

I think the best practice is to have 1 controller for each FXML file. The DataFX framework provides a flow API in the newest version (2b07 - Release 2.0 will follow in a few weeks) that do exactly what you need: http://www.javafxdata.org/overview_flow.html


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon