Reputation: 2259
i have GridPane Objects like
GridPane gridPane1 = new GridPane();
gridPane1.add(label1, 0, 0);
gridPane1.add(label2, 1, 0);
gridPane1.add(label3, 0, 1);
gridPane1.add(label4, 1, 1);
and
GridPane gridPane2 = new GridPane();
gridPane2.add(label1, 0, 0);
gridPane2.add(label2, 1, 0);
gridPane2.add(label3, 0, 1);
gridPane2.add(label4, 1, 1);
Now How can i add this object to tableView of javafx.?
Upvotes: 0
Views: 2682
Reputation: 6574
You should be aware that JavaFX TableView doesn't actually work like a grid where you can add arbitrary objects into it. Rather, a TableView is a way of displaying POJOs in rows, where the visual appearance of the contents of a single cell are determined by CellFactories in the TableColumn. Please read this to understand how a TableView works.
That said, i propose to use a different approach to your request: Add both GridPanes into a HBox and style the HBox so it looks like a table or the like (this works easily via css). If you really want to use a TableView, the solution would be to use a POJO with two properties: the first GridPane and the second Gridpane. Then use two TableColumn cell factories which return the appropriate GridPane of the POJO, this way you hardcode those things into your TableView.
Upvotes: 1