Alternative to replace the SideMenu of JFoenix

2

I am working with JavaFX , specifically with the JFoenix library.

In my project I replaced the NavigationDrawer of the demo ( SideMenu ) with a JFXListView within the interface (the space inside the red rectangle). The programming of the controllers is identical to the demo, however when I click on the option "Tags" it does not replace the table with the new content.

Any ideas on how to solve this?

Screenshot:

    
asked by Michel Escalante Álvarez 15.05.2017 в 19:49
source

1 answer

2

To achieve what you want, try this:

  • Create the JFXListView in the fchero xml, for example:

    <JFXListView
    fx:id="list"
    maxWidth="208.0"
    minWidth="210.0"
    prefWidth="208.0"
    style="-fx-margin: 0 0 0 10;"
    onMouseClicked="#submit"
    fx:controller="MainController">
        <Label fx:id="label1">Label 1</Label>
        <Label fx:id="label2">Label 2</Label>
    </JFXListView>
    
  • In my case I put it in an fxml file called Lista.fxml which I then included within Main.fxml . It was necessary to create the association with the controller MainController .

  • In the method init() of the controller MainController registers the classes to which the Labels of the list will be linked (following the demo example):

    innerFlow.withGlobalLink(label1.getId(), ClaseControladora1.class);
    innerFlow.withGlobalLink(label2.getId(), ClaseControladora2.class);
    
  • Create the submit method within the controller to handle the onclick on the list:

    @FXML
    private void submit() {
    try {
    FlowHandler contentFlowHandler = (FlowHandler) 
    context.getRegisteredObject("ContentFlowHandler");
    
    contentFlowHandler.handle(list.getSelectionModel(). 
    getSelectedItem().getId());
    } catch (FlowException e) {
    e.printStackTrace();
    } catch (VetoException e) {
    e.printStackTrace();
    }
    }
    
  • Note: I had to add a space after getSelectionModel(). because otherwise the code was not indexed here, be careful when copying it, delete that space.

    I hope it serves you.

        
    answered by 16.05.2017 / 16:51
    source