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.