I making a logging GUI and my main view is a TableView with columns name loaded from a config file.
String format="Type:Date:Message";
//OR
String format="A:Different:Number:Of:Column";
String[] tok = format.split(":");
logTable.getColumns().clear();
for (String s : tok) {
TableColumn<LogLine, String> col = new TableColumn<LogLine, String>(s);
logTable.getColumns().add(col);
}
This works as expected. (I see the corrects column headers in my app). Then I want to add a CellValueFactory for each column:
ObservableList<TableColumn<LogLine, ?>> colList =logTable.getColumns();
for (int i = 0; i < colList.size(); i++)
{
colList.get(i).setCellValueFactory(cellData -> cellData.getValue().getTokens()[i]);
// ...
}
This is not working because java complains about i not defined in the lambda function:
Caused by: java.lang.Error: Unresolved compilation problem:
Local variable i defined in an enclosing scope must be final or effectively final
Any ideas to do it ? It's maybe a bad way, i'm new to Java/JavaFX.
Many thanks !
Aucun commentaire:
Enregistrer un commentaire