javafx.scene.control.TableColumn类的使用及代码示例

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

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

TableColumn介绍

暂无

代码示例

代码示例来源: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"));
propertyTypeColumn.setCellValueFactory(new PropertyValueFactory<>("typeId"));
propertyNameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
propertyValueColumn.setCellFactory(TextFieldTableCell.forTableColumn());
this.setEditable(false);

代码示例来源: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: stackoverflow.com

for (Object col : playListTableView.getColumns()) {
       TableColumn colCasted = ((TableColumn)col);
   if(colCasted.getText().equals("Artist")){
      colCasted.setVisible(false);
   }
 }

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

logDateColumn.setCellValueFactory(entry -> new SimpleObjectProperty<>(entry.getValue()));
logDateColumn.setCellFactory(column -> new TableCell<LogEntry, LogEntry>() {
logCategoryColumn.setCellValueFactory(new PropertyValueFactory<>("category"));
logMessageColumn.setCellValueFactory(new PropertyValueFactory<>("message"));
logMessageColumn.setSortable(false);
logMessageColumn.setCellFactory(col -> {
  TableCell<LogEntry, String> cell = new TableCell<>();
  Text text = new Text();
logMessageColumn.prefWidthProperty()
        .bind(eventLogTableView.widthProperty()
                    .subtract(logCategoryColumn.getPrefWidth())
                    .subtract(logDateColumn.getPrefWidth())
                    .subtract(2)); // makes it work

代码示例来源: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: 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.jrebirth.af.showcase/todos

final TableColumn<Todo, Boolean> doneColumn = new TableColumn<>("Done");
doneColumn.setId(DONE_COLUMN);
doneColumn.setPrefWidth(40);
doneColumn.setMaxWidth(40);
doneColumn.setMinWidth(40);
doneColumn.setCellValueFactory(cdf -> cdf.getValue().pDone());
final TableColumn<Todo, String> textColumn = new TableColumn<>("Text");
textColumn.setId(TEXT_COLUMN);
textColumn.setPrefWidth(200);
textColumn.setMinWidth(100);
textColumn.setEditable(true);
textColumn.setCellValueFactory(this::getColumnContent);
textColumn.setCellFactory(this::getTableCell);

代码示例来源:origin: tech.tablesaw/tablesaw-plot

/**
   * Build a TableView {@link TableColumn} from a Tablesaw {@link Column}
   * @param col a Tablesaw {@link Column}
   * @return a TableView {@link TableColumn}
   */
  private TableColumn<Integer, String> createColumn(Column col) {

    // the name is just the column name
    TableColumn<Integer, String> stringColumn = new TableColumn<>(col.name());
    // Setup the cell value factory: return the string representation of the value at the given index
    stringColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Integer, String>, ObservableValue<String>>() {
      @Override
      public ObservableValue<String> call(TableColumn.CellDataFeatures<Integer, String> param) {
        int rowIndex = param.getValue();
        String name = col.getString(rowIndex);

        return new SimpleStringProperty(name);
      }
    });
    return stringColumn;
  }
}

代码示例来源:origin: org.javafxdata/datafx-ui

TableColumn column = new TableColumn();
column.setText(displayName);
column.setCellValueFactory(new PropertyValueFactory(pd.getName()));
columns.add(column);
  column.setCellFactory(ChoiceBoxTableCell.forTableColumn(enumConstants));
} else if (propertyDataType == boolean.class) {
  column.setCellFactory(CheckBoxTableCell.forTableColumn(column));
} else if (propertyDataType == String.class) {
  column.setCellFactory(TextFieldTableCell.forTableColumn());

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

TableColumn<Person, String> firstNameCol = new TableColumn<Person, String>("First Name");
firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));
TableColumn lastNameCol = new TableColumn("Last Name");
lastNameCol.setEditable(true);
lastNameCol.setCellFactory(TextFieldTableCell.forTableColumn());
lastNameCol.setOnEditCommit(new EventHandler<CellEditEvent<Person, String>>() {
  @Override public void handle(CellEditEvent<Person, String> t) {
    ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setLastName(t.getNewValue());
lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));
TableColumn<Person, String> firstEmailCol = new TableColumn<Person, String>("Primary");
firstEmailCol.setMinWidth(200);
firstEmailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("primaryEmail"));
TableColumn<Person, String> secondEmailCol = new TableColumn<Person, String>("Secondary");
secondEmailCol.setMinWidth(200);
secondEmailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("secondaryEmail"));
TableColumn<Person, Boolean> vipCol = new TableColumn<Person, Boolean>("VIP");
vipCol.setEditable(true);
vipCol.setCellFactory(CheckBoxTableCell.forTableColumn(vipCol));
final Callback<TableColumn<Person, Boolean>, TableCell<Person, Boolean>> cellFactory = CheckBoxTableCell.forTableColumn(vipCol);
vipCol.setCellFactory(new Callback<TableColumn<Person, Boolean>, TableCell<Person, Boolean>>() {
  @Override public TableCell<Person, Boolean> call(TableColumn<Person, Boolean> column) {
    TableCell<Person, Boolean> cell = cellFactory.call(column);
vipCol.setOnEditCommit(new EventHandler<CellEditEvent<Person, Boolean>>() {

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

firstNameCol = new TableColumn<Person, String>();
firstNameCol.setText("First");
firstNameCol.setCellValueFactory(new PropertyValueFactory<Person,String>("firstName"));
firstNameCol.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<Person, String>>() {
  @Override public void handle(TableColumn.CellEditEvent<Person, String> t) {
    System.out.println("Edit commit event: " + t.getNewValue());
lastNameCol = new TableColumn<Person, String>();
lastNameCol.setGraphic(graphic1);
lastNameCol.setText("Last");
lastNameCol.setSortType(TableColumn.SortType.DESCENDING);
lastNameCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Person, String>, ObservableValue<String>>() {
  public ObservableValue<String> call(TableColumn.CellDataFeatures<Person, String> p) {
    return p.getValue().lastNameProperty();
nameCol = new TableColumn<Person, String>();
nameCol.setText("Name");
nameCol.getColumns().addAll(firstNameCol, lastNameCol);
emailCol = new TableColumn<Person, String>();
emailCol.setText("Email");
emailCol.setMinWidth(200);
emailCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Person, String>, ObservableValue<String>>() {
  public ObservableValue<String> call(TableColumn.CellDataFeatures<Person, String> p) {
    return p.getValue().emailProperty();
countryCol = new TableColumn<Person, String>();
countryCol.setText("Country");
countryCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Person, String>, ObservableValue<String>>() {

代码示例来源:origin: io.datafx/crud

public static <T> List<TableColumn<T, ?>> createColumns(Class<T> entityType, ExceptionHandler exceptionHandler) {
    List<TableColumn<T, ?>> columns = new ArrayList<>();
    for (Field field : entityType.getDeclaredFields()) {

      ViewColumn columnAnnotation = field.getAnnotation(ViewColumn.class);

      if (columnAnnotation != null) {
        TableColumn<T, ?> column = new TableColumn<>();
        column.setText(columnAnnotation.value());
        column.setEditable(columnAnnotation.editable());
        column.setSortable(columnAnnotation.sortable());
        column.setResizable(columnAnnotation.resizeable());
        column.setCellValueFactory(e -> {
          try {
            return new SimpleObjectProperty(DataFXUtils.getPrivileged(field, e.getValue()));
          } catch (Exception exception) {
            exceptionHandler.setException(exception);
            return null;
          }
        });
        columns.add(column);
      }
    }
    return columns;
  }
}

代码示例来源: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: 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.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.intuit.karate/karate-core

table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
setCenter(table);
TableColumn nameCol = new TableColumn("Variable");
nameCol.setCellValueFactory(new PropertyValueFactory("name"));
nameCol.setCellFactory(c -> new StringTooltipCell());
TableColumn typeCol = new TableColumn("Type");
typeCol.setMinWidth(45);
typeCol.setMaxWidth(60);
typeCol.setCellValueFactory(new PropertyValueFactory("type"));
TableColumn<Var, ScriptValue> valueCol = new TableColumn("Value");
valueCol.setCellValueFactory(c -> new ReadOnlyObjectWrapper(c.getValue().getValue()));        
valueCol.setCellFactory(c -> new VarValueCell());
table.getColumns().addAll(nameCol, typeCol, valueCol);
table.setItems(getVarList());

代码示例来源: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: com.powsybl/powsybl-gse-security-analysis

equipmentColumn.setPrefWidth(200);
equipmentColumn.setCellFactory(stringColumnFactory);
equipmentColumn.setCellValueFactory(callback -> new SimpleObjectProperty<>(callback.getValue().getSubjectId()));
TableColumn<LimitViolation, String> violationTypeColumn = createColumn("ViolationType");
violationTypeColumn.setPrefWidth(150);
violationTypeColumn.setCellFactory(stringColumnFactory);
violationTypeColumn.setCellValueFactory(callback -> new SimpleObjectProperty<>(callback.getValue().getLimitType().name()));
TableColumn<LimitViolation, String> violationNameColumn = createColumn("ViolationName");
violationNameColumn.setPrefWidth(150);
violationNameColumn.setCellFactory(stringColumnFactory);
violationNameColumn.setCellValueFactory(callback -> new SimpleObjectProperty<>(callback.getValue().getLimitName()));
TableColumn<LimitViolation, Double> limitColumn = createColumn("Limit");
limitColumn.setCellFactory(decimalColumnFactory);
limitColumn.setCellValueFactory(callback -> new SimpleObjectProperty<>(callback.getValue().getLimit()));
TableColumn<LimitViolation, Double> valueColumn = createColumn("Value");
valueColumn.setCellFactory(decimalColumnFactory);
valueColumn.setCellValueFactory(callback -> new SimpleObjectProperty<>(callback.getValue().getValue()));
TableColumn<LimitViolation, Double> loadColumn = createColumn("Load");
loadColumn.setPrefWidth(150);
loadColumn.setCellFactory(decimalColumnFactory);
loadColumn.setCellValueFactory(callback -> {
  LimitViolation violation = callback.getValue();
  double load = violation.getValue() / (violation.getLimit() * violation.getLimitReduction()) * 100;

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

public class MainWindowController implements Initializable {
  @FXML
  public TableColumn levelOfGrowthColumn;

  /**
   * Initializes the controller class.
   */
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    ObservableList<Person> persons = FXCollections.observableArrayList();

    persons.add(new Person(0));
    persons.add(new Person(0.5));
    persons.add(new Person(1));

    levelOfGrowthColumn.setCellValueFactory(new PropertyValueFactory<Person, Double>("levelOfGrowth"));

  }
}

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

/**
 * Create a column
 *
 * @param label
 *            the label
 * @param prefWidth
 *            the preferred width
 * @param valueExtractor
 *            function to extract the value
 * @return the column instance
 */
public static <S, T> TableColumn<S, T> createColumn(String label, double prefWidth, Function<S, T> valueExtractor) {
  TableColumn<S, T> c = new TableColumn<>();
  c.setText(label);
  c.setPrefWidth(prefWidth);
  c.setCellValueFactory(f -> new SimpleObjectProperty<>(valueExtractor.apply(f.getValue())));
  return c;
}

相关文章