I have a combo box and I set the default value for this combo box at the initialisation of the node. However, once there is some data retrieved from a database I want to update this default value to something else.
initialise() {
businessDateComboBox.setItems(config.retrievedPositionsData().getDistinctBusinssDate());
businessDateComboBox.setValue(config.retrievedPositionsData().getCurrentBusinessDate().toString());
}
The setItems is an ObservableList and the setValue is an ObservableList to but ive converted it to string.
Now I use a separate thread to retrieve items from database.
public void readPositionsFromDataBase() throws Exception {
Task<Integer> task = new Task<Integer>() {
@Override protected Integer call() throws Exception {
config.positionViewPersister().readDataFromDataBase(null,null);
return 0;
}
};
Thread th = new Thread(task);
th.setDaemon(true);
th.start();
config.retrievedPositionsData().setCurrentBusinessDate("56")
}
Once this finishes I want to update the User Interface with the latest value retrieved for default combo box value. I do this by reloading the FXML and the corresponding controller of the FXML which consists of the initialise method - currently the initialise method is run again but the user interface does not get updated with the latest value. Does anyone know why?
The default value in combo box in user interface should now be 56 as ive set it. When I print businessDateComboBox.getValue() it gives 56 it just isn't updating the User Interface.
Is there any equivalent of the swing redraw or something?