1

如何在我的表中创建一个对象(按钮,复选框)?

    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=button]'CLICK'

Button@3ad2325d[styleClass=button]'CLICK'

4

1 回答 1

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);
于 2015-05-09T19:11:00.407 回答