How to Use ‘CardLayout’ like Panel with JRebirth StackModel

JRebirth Application Framework provides a custom ‘CardLayout’ as a JRebirth component by using its dedicated pattern wB-CSMvc.

The StackModel class will do the job (provided by artifact), you can find 2 usages here and here.

Each ‘card’ model can be called using a enum|modelKey identifier, and each stack has an unique name.

The first sample is used for the JRebirth Demo Application, it’s a pretty simple application that will allow to display other JRebirth showcase applications dynamically loaded as JRebirth module (from a separate and independent jar).

This application will load its first model (MainModel) and put its root node into the scene root node (StackPane, automatically built).The MainModel will list all application’s sub modules to add a button entries into its left menu, and a StackModel that will display each module content. The StackModel is loaded using special annotation using its unique String key.

The MainView will be in charge to create the module menu:

And the MainController will load the Module content when any menu button is triggered:

The second example will load the StackModel as an innerComponent and each card will be identified by an enum entry (stored into FXMLPage), let’s see FXMLShowCaseModel :

The enumeration that link enum entry with Model:

As the card list is known, toolbar item are statically created into FXMLShowCaseView and event handling is also staically defined into FXMLShowCaseController using another technique:

Here you have the final application that allows to open each module dependency into the Stack using a Toggle button


Leave a Reply