如何在表格中创建对象(按钮,复选框)?
GridBase grid = new GridBase(20, 20);
ObservableList<ObservableList<SpreadsheetCell>> rows = FXCollections.observableArrayList();
for (int row = 0; row < grid.getRowCount(); ++row) {
final ObservableList<SpreadsheetCell> list = FXCollections.observableArrayList();
for (int column = 0; column < grid.getColumnCount(); ++column) {
list.add(new ObjectType().createCell(row, column, 1, 1, new Button("CLICK")));
}
rows.add(list);
}
grid.setRows(rows);
SpreadsheetView spv = new SpreadsheetView(grid);
表中的输出:
按钮@ 79280814 [的styleClass =按钮]&#39; CLICK&#39;
按钮@ 3ad2325d [的styleClass =按钮]&#39; CLICK&#39;
答案 0 :(得分:1)
我想我已经找到了它。)
1 - )
SpreadsheetCellBase cell = new SpreadsheetCellBase(row, column, 1, 1);
cell.setGraphic(new Button("Test Button"));
list.add(cell)
2 - )
SpreadsheetCell cellIndex = SpreadsheetCellType.STRING.createCell(row, column, 1, 1,null);
cellIndex.setGraphic(new Button("Test Button"));
cells.add(cellIndex);