I have a TabPane with test button which calls this code:
Button bt1 = new Button("Select");
bt1.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(final ActionEvent event)
{
TreeClass.getConnectedAgentsMap();
TreePane.getTreeView().getSelectionModel().clearAndSelect(3);
}
});
This code selects TreeNode into TreeView:
cell.setOnMouseClicked((MouseEvent me) ->
{
if (!cell.isEmpty())
{
/// some action
}
});
As you can see this event is triggered when mouse selects tree row. I tried to call the tree cell action with this code:
cell.selectedProperty().addListener(new ChangeListener<Boolean>()
{
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue)
{
/// Some Action
}
});
But it's not the proper way to use it because several times new Tab is opened. Is there a way when I click the button to call action event?