Ravendyne Inc

DynamoFX on

DynamoFX is a toolkit designed to help with building JavaFX based UI.

Originally, JavaFX UI can be built by either in code or via FXML files.

Code quckly becomes cumbersome and FXML is XML which is designed to be more machine-friendly than human-friendly so DynamoFX was born. Initially, it was made to be used for quickly building simpler, tool-oriented UIs, and as time went by, it covered more and more UI components and got few more features.

With JavaFX based applications you would extend javafx.application.Application and then build you GUI in start() method override.

With DynamoFX, you would have your application main source file, i.e. SampleApp.java together with a .dynamofx file, i.e. appui.dynamofx which describes your GUI.

SampleApp.java may look something like this:

    public class TimerApp extends Application {
        @Inject Button btnStopAll;
        @Inject Button btnStartAll;
        @Inject Button btnStartInactivity;
        @Inject Button btnStopInactivity;
        
        @Inject Label labelInactivityTimer;
        @Inject Label labelSessionTimer;
        
        @Inject Pane blinkerPane;

        @Override
        public void start(Stage primaryStage) throws Exception {

            // .... code, code, code and then ....
            List<String> guiConfig = AmpResources.loader.loadTextFile("appui.dynamofx");

            Parent guiNode = DynamoFxComponent
                    .newInstance("test", guiConfig)
                    .setResourceLoader( ChainSimResources.loader )
                    .injectInto( this )
                    .build();
            
            setupGui();


            // .... code, code, code and then ....
            Scene scene = new Scene(guiNode);
            primaryStage.setScene(scene);

            // .... code, code, code and then ....
            primaryStage.show();
        }

        private void setupGui() {

            // typically you wire up event handlers here, i.e.
            btnStartAll.setOnMouseClicked((e)->{
                startAll();
            });
            btnStopAll.setOnMouseClicked((e)->{
                stopAll();
                stopBeep();
            });
            // etc. etc. etc.
        }
    }

and appui.dynamofx may look something like this:

gui {
    BorderPane {
        width: 320
        height: 240
        cssClass: border-pane
        top {
            TextArea {
                id: textLog
                rows: 3
            }
        }
        center {
            VBox {
                c <
                HBox {
                    c <
                    Label {
                        id: labelInactivityTimer
                        cssClass: timer-label
                        text: 00:00:00
                    }
                    Label {
                        text: Inactivity timer
                        cssClass: timer-caption-label
                    }
                    >
                }
                HBox {
                    c <
                    Label {
                        id: labelSessionTimer
                        cssClass: timer-label
                        text: 00:00:00
                    }
                    Label {
                        text: Session timer
                        cssClass: timer-caption-label
                    }
                    >
                }
                Pane {
                    id: blinkerPane
                    width: 320
                    height: 70
                }
                >
            }
        }
        bottom {
            HBox {
                c <
                Button {
                    id: btnStartAll
                    text: Start all
                }
                Button {
                    id: btnStopAll
                    text: Stop all
                }
                Button {
                    id: btnStartInactivity
                    text: (Re)start inactivity
                }
                Button {
                    id: btnStopInactivity
                    text: Stop inactivity
                }
                >
            }
        }
    }
}

and then, once you launch your app, you may end up with this GUI:

You can have more than one .dynamofx file per application, each for some part of UI, and load them as needed. Also, you can have multiple UI definitions in one .dynamofx file and you can select which one is used when loading the file.

DynamoFX supports creating a number of JavaFX comnponents, list of which can be found in Builders.java file and it supports setting a number of attributes for those components, list of which can be found in Attributes.java file.

Thanks to its modular and leveled design, it is simple and straightforward to add more components and/or attributes as needed.

For more details, checkout the Git repo.