Frage

Hello we tried to use an eventhandler for our comboBox in our tableView. But for some reason the eventhandler won't start. After a long search we still didn't find no answer so we are desperate. Here is our code:

//ComboBoxes in Tableview
   @FXML
    private TableColumn<Presentatie, Dag> dagC;
    dagC.setCellValueFactory(new PropertyValueFactory<Presentatie, Dag>("dag"));
    dagC.setEditable(true);
    dagC.setCellFactory(ComboBoxTableCell.<Presentatie, Dag>forTableColumn(dataD));

    EventHandler<TableColumn.CellEditEvent<Presentatie, Dag>> nameEditHandler = new EventHandler<TableColumn.CellEditEvent<Presentatie, Dag>>() {
        @Override
        public void handle(TableColumn.CellEditEvent<Presentatie, Dag> e) {
            Presentatie p = e.getRowValue();
            Dag newValue = e.getNewValue();
            p.setDag(newValue);
            System.out.println("PLEASE");

        }
    };
    dagC.setOnEditCommit(nameEditHandler);

And our dataD is an FXCollections.observableArrayList.

We are working with scene builder, is this perhaps the problem? We read somewhere that scene builder doesn't update the event handlers. If so what do we need to do to make this code work? Please help we would be so grateful.

War es hilfreich?

Lösung

The scene builder is not the problem. For some reason displaying Strings with the value null causes problems. A solution is replacing the null values with empty "" Strings.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top