javafx.scene.control.TableColumn.setCellFactory()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(247)

本文整理了Java中javafx.scene.control.TableColumn.setCellFactory()方法的一些代码示例,展示了TableColumn.setCellFactory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableColumn.setCellFactory()方法的具体详情如下:
包路径:javafx.scene.control.TableColumn
类名称:TableColumn
方法名:setCellFactory

TableColumn.setCellFactory介绍

暂无

代码示例

代码示例来源:origin: pmd/pmd

Collections.sort(availableBuilders);
StringConverter<PropertyTypeId> converter = DesignerUtil.stringConverter(PropertyTypeId::getStringId, PropertyTypeId::lookupMnemonic);
propertyTypeColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(converter, availableBuilders));
propertyNameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
propertyValueColumn.setCellValueFactory(new PropertyValueFactory<>("value"));
propertyNameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
propertyValueColumn.setCellFactory(TextFieldTableCell.forTableColumn());
this.setEditable(false);

代码示例来源:origin: pmd/pmd

logDateColumn.setCellFactory(column -> new TableCell<LogEntry, LogEntry>() {
logMessageColumn.setCellFactory(col -> {
  TableCell<LogEntry, String> cell = new TableCell<>();
  Text text = new Text();

代码示例来源:origin: torakiki/pdfsam

@Override
public TableColumn<SelectionTableRowData, Boolean> getTableColumn() {
  TableColumn<SelectionTableRowData, Boolean> tableColumn = new TableColumn<>(getColumnTitle());
  tableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(tableColumn));
  tableColumn.setCellValueFactory(
      new Callback<CellDataFeatures<SelectionTableRowData, Boolean>, ObservableValue<Boolean>>() {
        @Override
        public ObservableValue<Boolean> call(CellDataFeatures<SelectionTableRowData, Boolean> param) {
          if (param.getValue() != null) {
            return param.getValue().reverse;
          }
          return null;
        }
      });
  return tableColumn;
}

代码示例来源:origin: torakiki/pdfsam

@Override
default TableColumn<SelectionTableRowData, T> getTableColumn() {
  TableColumn<SelectionTableRowData, T> tableColumn = new TableColumn<>(getColumnTitle());
  tableColumn.setCellFactory(cellFactory());
  tableColumn.setCellValueFactory(cellValueFactory());
  tableColumn.setComparator(comparator());
  return tableColumn;
}

代码示例来源:origin: stackoverflow.com

levelOfGrowthColumn.setCellFactory(percantageCellFactory);

代码示例来源:origin: torakiki/pdfsam

@Override
public TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> getTableColumn() {
  TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> tableColumn = new TableColumn<>(getColumnTitle());
  tableColumn.setCellFactory(cellFactory());
  tableColumn.setCellValueFactory(cellValueFactory());
  tableColumn.setComparator(null);
  tableColumn.setSortable(false);
  tableColumn.setMaxWidth(26);
  tableColumn.setMinWidth(26);
  return tableColumn;
}

代码示例来源:origin: org.copper-engine/copper-monitoring-client

public static <T, U> void setTextOverrunCellFactory(TableColumn<T, U> column, final OverrunStyle overrunStyle) {
  column.setCellFactory(new Callback<TableColumn<T, U>, TableCell<T, U>>() {
    @Override
    public TableCell<T, U> call(TableColumn<T, U> param) {
      TextFieldTableCell<T, U> cell = new TextFieldTableCell<T, U>();
      cell.setTextOverrun(overrunStyle);
      return cell;
    }
  });
}

代码示例来源:origin: org.copper-engine/copper-monitoring-client

public static <T, U> void setConverterCellFactory(TableColumn<T, U> column, final StringConverter<U> converter) {
  column.setCellFactory(new Callback<TableColumn<T, U>, TableCell<T, U>>() {
    @Override
    public TableCell<T, U> call(TableColumn<T, U> param) {
      return new TextFieldTableCell<T, U>(converter);
    }
  });
}

代码示例来源:origin: stackoverflow.com

Callback<TableColumn, TableCell> checkboxCellFactory = new Callback<TableColumn, TableCell>() {
   @Override
   public TableCell call(TableColumn p) {
     return new CheckboxCell();
   }
 };
 TableColumn selectColumn = (TableColumn) tbvDatos.getColumns().get(1);
 selectColumn.setCellValueFactory(new PropertyValueFactory("selected"));
 selectColumn.setCellFactory(checkboxCellFactory);

代码示例来源:origin: org.codehaus.griffon.plugins/griffon-glazedlists-javafx

@SuppressWarnings("unchecked")
protected <T> void processTableFormat(@Nonnull TableColumn<E, T> column, String columnName, int columnIndex) {
  column.setCellValueFactory(cell -> (ObservableValue<T>) format.getColumnObservableValue(cell.getValue(), columnIndex));
  column.setCellFactory(param -> format.getTableCellFactory(columnIndex).createTableCell(param));
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

private void addSelectColumn() {
 headerCheckboxCol.setPrefWidth(40);
 headerCheckboxCol.setCellValueFactory(new PropertyValueFactory<>("selected"));
 headerCheckboxCol.setCellFactory(param -> buildCell());
 headerCheckboxCol.setGraphic(headerColCheckbox);
 headerCheckboxCol.setVisible(false);
 tableView.getColumns().add(0, headerCheckboxCol);
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

@SuppressWarnings({"unchecked"})
private void addSelectColumn() {
 headerCheckboxCol.setPrefWidth(40);
 headerCheckboxCol.setCellValueFactory(new PropertyValueFactory<>("selected"));
 headerCheckboxCol.setCellFactory(param -> buildCell());
 headerCheckboxCol.setGraphic(headerColCheckbox);
 headerCheckboxCol.setVisible(false);
 tableView.getColumns().add(0, headerCheckboxCol);
}

代码示例来源:origin: ssaring/sportstracker

@Override
protected void setupTableColumns() {
  // setup factories for providing cell values
  tcDate.setCellValueFactory(new PropertyValueFactory<>("dateTime"));
  tcWeight.setCellValueFactory(new PropertyValueFactory<>("value"));
  tcComment.setCellValueFactory(cellData -> new SimpleStringProperty( //
      StringUtils.getFirstLineOfText(cellData.getValue().getComment())));
  // setup custom factories for displaying cells
  tcDate.setCellFactory(new LocalDateCellFactory<>());
  tcWeight.setCellFactory(new FormattedNumberCellFactory<>(value -> //
      value == null ? null : getContext().getFormatUtils().weightToString(value.floatValue(), 2)));
}

代码示例来源:origin: org.codehaus.griffon/griffon-javafx

@SuppressWarnings("unchecked")
protected void computeColumns() {
  for (int i = 0; i < format.getColumnCount(); i++) {
    final String columnName = format.getColumnName(i);
    TableColumn column = new TableColumn(columnName);
    final int columnIndex = i;
    final TableCellFactory tableCellFactory = format.getTableCellFactory(i);
    if (tableCellFactory != null) {
      column.setCellFactory(cell -> tableCellFactory.createTableCell((TableColumn) cell));
    }
    column.setCellValueFactory(cell -> format.getObservableValue((E) ((TableColumn.CellDataFeatures) cell).getValue(), columnIndex));
    columns.add(column);
  }
}

代码示例来源:origin: org.copper-engine/copper-monitoring-client

public static <T> void setupEditableBooleanColumn(TableColumn<T, Boolean> column, final ColumnBooleanAccessor<T> propertyAccessor) {
  column.getTableView().setEditable(true);
  column.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<T, Boolean>, ObservableValue<Boolean>>() {
    @Override
    public ObservableValue<Boolean> call(CellDataFeatures<T, Boolean> param) {
      return propertyAccessor.getProperty(param.getValue());
    }
  });
  column.setOnEditCommit(new EventHandler<CellEditEvent<T, Boolean>>() {
    @Override
    public void handle(CellEditEvent<T, Boolean> t) {
      propertyAccessor.getProperty(t.getRowValue()).setValue(t.getNewValue());
    }
  });
  column.setCellFactory(CheckBoxTableCell.forTableColumn(column));
  column.setEditable(true);
}

代码示例来源:origin: org.copper-engine/copper-monitoring-client

/**
 * T Tableobject
 * Column Display Type
 */
public static <T> void setupEditableStringColumn(TableColumn<T, String> column, final ColumnStringAccessor<T> propertyAccessor) {
  column.getTableView().setEditable(true);
  column.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<T, String>, ObservableValue<String>>() {
    @Override
    public ObservableValue<String> call(CellDataFeatures<T, String> param) {
      return propertyAccessor.getProperty(param.getValue());
    }
  });
  column.setEditable(true);
  column.setOnEditCommit(new EventHandler<CellEditEvent<T, String>>() {
    @Override
    public void handle(CellEditEvent<T, String> t) {
      propertyAccessor.getProperty(t.getRowValue()).setValue(t.getNewValue());
    }
  });
  column.setCellFactory(new Callback<TableColumn<T, String>, TableCell<T, String>>() {
    @Override
    public TableCell<T, String> call(TableColumn<T, String> param) {
      return new EditingCell<T>();
    }
  });
}

代码示例来源:origin: ssaring/sportstracker

@Override
protected void setupTableColumns() {
  // setup factories for providing cell values
  tcDate.setCellValueFactory(new PropertyValueFactory<>("dateTime"));
  tcComment.setCellValueFactory(cellData -> new SimpleStringProperty( //
      StringUtils.getFirstLineOfText(cellData.getValue().getComment())));
  // setup custom factories for displaying cells
  tcDate.setCellFactory(new LocalDateCellFactory<>());
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

private TableColumn buildRootColumn() {
 final TableColumn t = new TableColumn();
 // cell value factory
 t.setCellValueFactory(param -> {
  if (((CellDataFeatures) param).getValue() instanceof OperationData) {
   final OperationData operationData = (OperationData) ((CellDataFeatures) param).getValue();
   final SimpleObjectProperty<OperationData> op = new SimpleObjectProperty();
   op.set(operationData);
   return op;
  }
  return null;
 });
 t.setPrefWidth(600);
 t.setMinWidth(600);
 // cell factory
 t.setCellFactory(arg0 -> new FlowTableCell());
 return t;
}

代码示例来源:origin: org.tentackle/tentackle-fx

/**
 * Creates a totals column from the original bound column.
 *
 * @param boundColumn the original column
 * @return the totals column
 */
@SuppressWarnings("unchecked")
protected TableColumn<S,?> createTotalsColumn(TableColumn<S,?> boundColumn) {
 TableColumn totalsColumn = new TableColumn<>();
 if (isSummable(boundColumn)) {
  totalsColumn.setCellValueFactory(boundColumn.getCellValueFactory());
  totalsColumn.setCellFactory(boundColumn.getCellFactory());
 }
 // sync column widths
 totalsColumn.prefWidthProperty().bind(boundColumn.widthProperty());
 // sync visibility
 totalsColumn.visibleProperty().bind(boundColumn.visibleProperty());
 return totalsColumn;
}

代码示例来源:origin: com.aquafx-project/aquafx

private void buildTableViewTab(Tab tab) {
  GridPane grid = new GridPane();
  grid.setPadding(new Insets(5, 5, 5, 5));
  grid.setHgap(5);
  grid.setVgap(5);
  // create the tableview
  TableColumn<TestPerson, Boolean> invitedColumn = new TableColumn<TestPerson, Boolean>("Invited");
  invitedColumn.setCellValueFactory(new PropertyValueFactory<TestPerson, Boolean>("invited"));
  TableColumn<TestPerson, String> nameColumn = new TableColumn<TestPerson, String>("First Name");
  nameColumn.setCellValueFactory(new PropertyValueFactory<TestPerson, String>("firstName"));
  TableView<TestPerson> tableView = new TableView<TestPerson>(data);
  tableView.getColumns().setAll(invitedColumn, nameColumn);
  // set the cell factory in the invited TableColumn
  invitedColumn.setCellFactory(CheckBoxTableCell.forTableColumn(invitedColumn));
  grid.add(tableView, 0, 0);
  GridPane.setVgrow(tableView, Priority.ALWAYS);
  GridPane.setHgrow(tableView, Priority.ALWAYS);
  tab.setContent(grid);
}

相关文章