dimanche 18 décembre 2016

Javafx SelectionListener for checked Checkboxes in CheckListView

i began to learn to handle Javafx, coming from SWT. So sorry for being a newbie.

I am looking for the typical "SelectionListener" of SWT in JavaFx, but based on a click on the checkboxes.

In SWT you can use the following code (and it works fine):

    list.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            //Do something
        }
    });

In JavaFx i found a possibilty for doing something on a selected row (the selected row will be marked in blue color):

    list.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<String>() {
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends String> c) {
            //Do something
        }
    });

Even this works fine. But i am looking for a possibility for having this second code based on a "Change" (Activating or deactivating) of checking one of the checkboxes.

Something like this:

list.getCheckModel().getCheckedItems().addListener(new ListChangeListener() { ... }

was compiled without problems, but it didn't work for me, if i check a checkbox.

Thanks for your help. Best regards. Alex




Aucun commentaire:

Enregistrer un commentaire