mercredi 13 mai 2015

Editing a table in JavaFx

I have created a table in JavaFx. I used reflection to populate the table with numbers 1 to 100. This table contains a zone number and a description. There are 100 zones. I want the table to be editable. I have used the following code to make the cells editable.

zonesTable.setEditable(true);
zone.setEditable(true);
zone.setCellFactory(TextFieldTableCell.<Zones>forTableColumn());

description.setEditable(true);
description.setCellFactory(TextFieldTableCell.<Zones>forTableColumn());

    zone.setCellValueFactory(new PropertyValueFactory<Zones, String>("rZoneNumber"));
    description.setCellValueFactory(new PropertyValueFactory<Zones, String>("rDescription"));

    for(int i = 0; i < 100; i++){
        data.add(new Zones(i + "", "")); 
    }

    zonesTable.setItems(data);

At the moment, this code adds numbers to the zone column and makes the zone and description column editable. However, after I type a value into the column and click the next row, my values that I input into the table disappear. I have no idea why. What do I need to do to cause my typed values to stay visible in the table after I select a different row than the one I am editing? Thanks in advance!





Aucun commentaire:

Enregistrer un commentaire