I want to create a dynamic tableview that gets its data from a json provided by a webpage. The thing is that whenever the data from the json is out of range (for example the range should be 0.8 - 0.9, but it reads 1.1), the table automatically updates the observablelist with a "RED SQUARE" image. If the data is within range, it shows a "BLUE SQUARE" image. It's like a status indicator so that the user knows if the data is correct or not. I have this code:
public ObservableList<PumpSites> list = FXCollections.observableArrayList(
new PumpSites (blue or red square image, "Canduman"),
new PumpSites (blue or red square image, "Cubacub"),
new PumpSites (blue or red square image, "Liloan"),
new PumpSites (blue or red square image, "Talamban"),
new PumpSites (blue or red square image, "Tisa")
);
status.setCellValueFactory(new PropertyValueFactory<PumpSites, String>("status"));
ps.setCellValueFactory(new PropertyValueFactory<PumpSites, String>("ps"));
table.setItems(list);
public class PumpSites {
private final SimpleStringProperty status;
private final SimpleStringProperty ps;
public PumpSites(String status, String ps){
super();
this.status = new SimpleStringProperty(status);
this.ps = new SimpleStringProperty(ps);
}
public String getStatus() {
return status.get();
}
public String getPs() {
return ps.get();
}
}
I have no problem getting data from the json. I am planning to put the dynamic reading of data for the status indicator inside a platform.runlater so that it updates always. How can I show a blue or red square beside the pump site in the table dynamically?