melkhaldi
melkhaldi

Reputation: 919

Java FX FXML and Controllers. Best Practices?

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?

Upvotes: 0

Views: 4784

Answers (2)

Puce
Puce

Reputation: 38152

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

Upvotes: 2

Hendrik Ebbers
Hendrik Ebbers

Reputation: 2600

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

Upvotes: 1

Related Questions