I am trying update the text of an index
in my ListView
when text is typed into a TextField
, but I don't know how to access the item to update the text. I know the index
of the item, but I just cant seem to figure out how to update the text..
@FXML
ListView connections;
public ObservableList names = FXCollections.observableArrayList();
@FXML
public void onInputChanged(KeyEvent event){
TextField fld = (TextField) event.getTarget();
if(fld.getId().equals("txtName") && index > -1){
}
}
names.set(index, fld.getText());
I think you need to use JavaFX Properties ie "SimpleStringProperty" to actually change the String in "names".
This link does explain it pretty accurately: https://gist.github.com/andytill/3116827
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.