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

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

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

TableColumn.<init>介绍

暂无

代码示例

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

private static <S, T> TableColumn<S, T> createColumn(String type) {
  TableColumn<S, T> column = new TableColumn<>(RESOURCE_BUNDLE.getString(type));
  column.setUserData(type);
  return column;
}

代码示例来源:origin: com.powsybl/powsybl-gse-security-analysis

private static <S, T> TableColumn<S, T> createColumn(String type) {
  TableColumn<S, T> column = new TableColumn<>(RESOURCE_BUNDLE.getString(type));
  column.setUserData(type);
  return column;
}

代码示例来源: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.codehaus.griffon.plugins/griffon-glazedlists-javafx

private void computeColumns() {
  for (int i = 0; i < format.getColumnCount(); i++) {
    String columnName = format.getColumnName(i);
    TableColumn<E, ?> column = new TableColumn<>(columnName);
    processTableFormat(column, columnName, i);
    if (format instanceof FXWritableTableFormat) {
      processWritableTableFormat(column, columnName, i);
    }
    columns.add(column);
  }
}

代码示例来源:origin: com.powsybl/powsybl-gse-spi

private static TableView<Version> createVersionTable() {
    TableView<Version> versionTable = new TableView<>();
    TableColumn<Version, String> repositoryNameCol = new TableColumn<>(RESOURCE_BUNDLE.getString("RepositoryName"));
    repositoryNameCol.setCellValueFactory(new PropertyValueFactory<>("repositoryName"));
    TableColumn<Version, String> mavenProjectVersionCol = new TableColumn<>(RESOURCE_BUNDLE.getString("MavenProjectVersion"));
    mavenProjectVersionCol.setCellValueFactory(new PropertyValueFactory<>("mavenProjectVersion"));
    TableColumn<Version, String> gitVersionCol = new TableColumn<>(RESOURCE_BUNDLE.getString("GitVersion"));
    gitVersionCol.setCellValueFactory(new PropertyValueFactory<>("gitVersion"));
    TableColumn<Version, String> gitBranchCol = new TableColumn<>(RESOURCE_BUNDLE.getString("GitBranch"));
    gitBranchCol.setCellValueFactory(new PropertyValueFactory<>("gitBranch"));
    TableColumn<Version, String> buildTimestampCol = new TableColumn<>(RESOURCE_BUNDLE.getString("BuildTimestamp"));
    buildTimestampCol.setCellValueFactory(param -> new SimpleStringProperty(new DateTime(param.getValue().getBuildTimestamp()).toString()));
    versionTable.getColumns().addAll(repositoryNameCol, mavenProjectVersionCol, gitVersionCol, gitBranchCol, buildTimestampCol);
    versionTable.getItems().addAll(Version.list());
    return versionTable;
  }
}

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

private void computeColumns() {
  for (int i = 0; i < format.getColumnCount(); i++) {
    final String columnName = format.getColumnName(i);
    TableColumn<E, Object> column = new TableColumn<>(columnName);
    final int columnIndex = i;
    column.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<E, Object>, ObservableValue<Object>>() {
      @Override
      @SuppressWarnings("unchecked")
      public ObservableValue<Object> call(final TableColumn.CellDataFeatures<E, Object> cell) {
        return new ReadOnlyObjectPropertyBase<Object>() {
          @Override
          public Object get() {
            return format.getColumnValue(cell.getValue(), columnIndex);
          }
          @Override
          public Object getBean() {
            return cell.getValue();
          }
          @Override
          public String getName() {
            return columnName;
          }
        };
      }
    });
    columns.add(column);
  }
}

代码示例来源: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;
}

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

@Override
public void showFilteredResult(List<SqlResultModel> filteredResult, SqlFilterModel usedFilter) {
  resultTable.getColumns().clear();
  if (!filteredResult.isEmpty()) {
    for (int i = 0; i < filteredResult.get(0).rows.size(); i++) {
      TableColumn<SqlResultModel, String> rowColumn = new TableColumn<SqlResultModel, String>();
      rowColumn.setText(filteredResult.get(0).rows.get(i).get());
      final int rowIndex = i;
      rowColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<SqlResultModel, String>, ObservableValue<String>>() {
        @Override
        public ObservableValue<String> call(CellDataFeatures<SqlResultModel, String> param) {
          return param.getValue().rows.get(rowIndex);
        }
      });// -3 for the border
      rowColumn.prefWidthProperty().bind(resultTable.widthProperty().subtract(3).divide(filteredResult.get(0).rows.size()));
      resultTable.getColumns().add(rowColumn);
    }
    ObservableList<SqlResultModel> content = FXCollections.observableArrayList();
    content.addAll(filteredResult);
    content.remove(0);
    setOriginalItems(resultTable, content);
  }
}

代码示例来源: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: 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: org.javafxdata/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: org.controlsfx/controlsfx

public TableModelTableView(final JavaFXTableModel<S> tableModel) {
    // create a dummy items list of the appropriate size, where the returned
    // value is the index of the row
    setItems(new ReadOnlyUnbackedObservableList<TableModelRow<S>>() {
      @Override public TableModelRow<S> get(int row) {
        if (row < 0 || row >= tableModel.getRowCount()) return null;
        TableModelRow<S> backingRow = new TableModelRow<>(tableModel, row);
        return backingRow;
      }

      @Override public int size() {
        return tableModel.getRowCount();
      }
    });
    
    setSortPolicy(table -> {
      tableModel.sort(table);
      return true;
    });
    
    // create columns from the table model
    for (int i = 0; i < tableModel.getColumnCount(); i++) {
      TableColumn<TableModelRow<S>,?> column = new TableColumn<>(tableModel.getColumnName(i));
      column.setCellValueFactory(new TableModelValueFactory<>(tableModel, i));
      getColumns().add(column);
    }
  }
}

代码示例来源: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: 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);
}

代码示例来源: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: io.github.factoryfx/javafxDataEditing

@Override
public Node createContent() {
  SplitPane splitPane = new SplitPane();
  splitPane.setOrientation(orientation);
  tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
  column = new TableColumn<>("Data");
  column.setCellValueFactory(param -> new DataObservableDisplayText(param.getValue()).get());
  tableView.getColumns().add(column);
  BorderPane borderPaneWrapper = new BorderPane();
  borderPaneWrapper.setCenter(tableView);
  SplitPane.setResizableWithParent(borderPaneWrapper, Boolean.FALSE);
  splitPane.getItems().add(borderPaneWrapper);
  Node dataEditorWidget = this.dataEditor.createContent();
  SplitPane.setResizableWithParent(dataEditorWidget, Boolean.TRUE);
  splitPane.getItems().add(dataEditorWidget);
  splitPane.setDividerPositions(dividerPosition);
  tableView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
    dataEditor.edit(newValue);
  });
  listEditWidget = new BorderPane();
  TableControlWidget tableControlWidget= new TableControlWidget<>(tableView, uniformDesign);
  Node tableControlWidgetContent = tableControlWidget.createContent();
  HBox hBox = new HBox();
  hBox.getChildren().addAll(listEditWidget, tableControlWidgetContent);
  HBox.setHgrow(tableControlWidgetContent, Priority.ALWAYS);
  HBox.setMargin(tableControlWidgetContent, new Insets(0,1,0,0));
  borderPaneWrapper.setBottom(hBox);
  tableView.setTableMenuButtonVisible(false);
  return splitPane;
}

代码示例来源:origin: org.jrebirth.af.showcase/todos

final TableColumn<Todo, Boolean> doneColumn = new TableColumn<>("Done");
doneColumn.setId(DONE_COLUMN);
doneColumn.setPrefWidth(40);
final TableColumn<Todo, String> textColumn = new TableColumn<>("Text");
textColumn.setId(TEXT_COLUMN);
textColumn.setPrefWidth(200);

相关文章