There is a two-dimensional array of numbers, it needs to be displayed in the TableView .

Closed due to the fact that off-topic participants are Alexey Shimansky , Grundy , Cerbo , Yuri Negometyanov , Alex 11 May '17 at 9:14 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The message contains only the text of the task, in which there is no description of the problem, or the question is purely formal (" how do I do this task ") . To reopen the question, add a description of the specific problem, explain what does not work, what you see the problem. " - Alexey Shimansky, Cerbo, Alex
If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    Here is a simple example of displaying the contents of a two-dimensional array in a TableView :

     public class Main extends Application { @Override public void start(Stage primaryStage) { StackPane rootStackPane = new StackPane(); String[][] dataArray = {{"First column", "Second column", "Third column", "Fourth column", "Fifth column"}, {"1", "2", "3", "4", "5",}, {"6", "7", "8", "9", "10",}, {"11", "12", "13", "14", "15"}}; ObservableList<String[]> observableList = FXCollections.observableArrayList(); observableList.addAll(Arrays.asList(dataArray)); observableList.remove(0); TableView<String[]> tableView = new TableView<>(); for (int i = 0; i < dataArray[0].length; i++) { TableColumn tableColumn = new TableColumn(dataArray[0][i]); int columnNumber = i; tableColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<String[], String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(TableColumn.CellDataFeatures<String[], String> p) { return new SimpleStringProperty((p.getValue()[columnNumber])); } }); tableView.getColumns().add(tableColumn); } tableView.setItems(observableList); rootStackPane.getChildren().add(tableView); primaryStage.setScene(new Scene(rootStackPane, 500, 500)); primaryStage.show(); } public static void main(String[] args) { launch(args); } } 

    Here dataArray is the original two-dimensional array.

    It looks like this:

    enter image description here

    • @ post_zeewThank you - OfficialDev