Created
October 5, 2012 11:25
-
-
Save rkotov93/3839316 to your computer and use it in GitHub Desktop.
Table Filling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressWarnings({ "rawtypes", "unchecked" }) | |
private void fillTable(Integer[][] matrix) { | |
matrixTable.getItems().clear(); | |
matrixTable.getColumns().clear(); | |
ObservableList<ObservableList> data = FXCollections.observableArrayList(); | |
for (int i = 0; i < matrix[0].length; i++) { | |
final int j = i; | |
TableColumn tc = new TableColumn(Integer.toString(i+1)); | |
tc.setCellValueFactory(new Callback<CellDataFeatures<ObservableList,String>,ObservableValue<String>>() { | |
public ObservableValue<String> call(CellDataFeatures<ObservableList, String> param) { | |
return new SimpleStringProperty(param.getValue().get(j).toString()); | |
} | |
}); | |
matrixTable.getColumns().addAll(tc); | |
} | |
for (int i = 0;i < matrix.length; i++) { | |
ObservableList<String> row = FXCollections.observableArrayList(); | |
for (int j = 0; j < matrix[0].length; j++) row.add(Integer.toString(matrix[i][j])); | |
data.add(row); | |
} | |
matrixTable.setItems(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment