当前位置: 首页>>代码示例>>Java>>正文


Java TreeTableColumn.setPrefWidth方法代码示例

本文整理汇总了Java中javafx.scene.control.TreeTableColumn.setPrefWidth方法的典型用法代码示例。如果您正苦于以下问题:Java TreeTableColumn.setPrefWidth方法的具体用法?Java TreeTableColumn.setPrefWidth怎么用?Java TreeTableColumn.setPrefWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.TreeTableColumn的用法示例。


在下文中一共展示了TreeTableColumn.setPrefWidth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupGroupView

import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
private void setupGroupView() {
	groupList = new JFXTreeTableView<>();

	TreeTableColumn<GroupTreeObject, String> nameColumn = new JFXTreeTableColumn<>("Name");
	nameColumn.setPrefWidth(150);
	nameColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<GroupTreeObject, String> param) -> {
		Group group = fromItem(param.getValue());
		if (group == null) {
			return new SimpleStringProperty();
		}
		return new SimpleStringProperty(group.getDisplayName());
	});
	groupList.getColumns().add(nameColumn);
	TreeItem treeItem = new TreeItem<>();
	treeItem.setExpanded(true);
	groupList.setRoot(treeItem);
	groupList.setShowRoot(false);
	groupList.setPrefHeight(Short.MAX_VALUE);
}
 
开发者ID:MakerTim,项目名称:LuckPermsUI,代码行数:20,代码来源:GroupListManager.java

示例2: getTestContainer

import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
@Override
protected Node getTestContainer() {
    treeOrTreeTableView = new TreeTableView<Data>();
    treeOrTreeTableView.setMinSize(300, 500);
    treeOrTreeTableView.setMaxSize(300, 500);
    treeOrTreeTableView.setPrefSize(300, 500);
    TreeTableColumn<Data, Node> column = new TreeTableColumn<Data, Node>("Items' name");
    column.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Data, Node>, ObservableValue<Node>>() {
        @Override
        public ObservableValue<Node> call(final TreeTableColumn.CellDataFeatures<Data, Node> p) {
            SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
            text.setValue(new Label(p.getValue().getValue().getData()));
            return text;
        }
    });
    column.setPrefWidth(150);
    ((TreeTableView) treeOrTreeTableView).getColumns().add(column);
    reset(0);
    return treeOrTreeTableView;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:21,代码来源:TreeTableAsOldTreeApp.java

示例3: addColumnString

import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
protected void addColumnString (String heading, int width, Justification justification,
    String propertyName)
{
  TreeTableColumn<T, String> column = new TreeTableColumn<> (heading);
  column.setPrefWidth (width);
  column
      .setCellValueFactory (new TreeItemPropertyValueFactory<T, String> (propertyName));
  getColumns ().add (column);

  if (justification == Justification.CENTER)
    column.setStyle ("-fx-alignment: CENTER;");
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:13,代码来源:DefaultTreeTable.java

示例4: addColumnNumber

import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
protected void addColumnNumber (String heading, int width, String propertyName)
{
  TreeTableColumn<T, Number> column = new TreeTableColumn<> (heading);
  column.setPrefWidth (width);
  column
      .setCellValueFactory (new TreeItemPropertyValueFactory<T, Number> (propertyName));
  getColumns ().add (column);
  column.setStyle ("-fx-alignment: CENTER-RIGHT;");
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:10,代码来源:DefaultTreeTable.java

示例5: createDescriptionColumn

import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
/**
 * Method to create a column in the table.
 * @param parent the {@link TreeTableView} parent to add the column to.
 * @param columnName the name of the column.
 * @param columnReference the index of the column in the table.
 * @param columnWidth the width of the column.
 */
private void createDescriptionColumn( TreeTableView< TestTableItem > parent, String columnName, int columnReference, int columnWidth ) {
   TreeTableColumn< TestTableItem, String > descriptionColumn = new TreeTableColumn<>( columnName );
   descriptionColumn.setPrefWidth( columnWidth );
   descriptionColumn.setEditable( false );
   descriptionColumn.setCellValueFactory( object -> object.getValue().getValue().getColumnProperty( columnReference ) );
   parent.getColumns().add( descriptionColumn );
}
 
开发者ID:DanGrew,项目名称:JttDesktop,代码行数:15,代码来源:TestTableView.java

示例6: render

import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
public void render() {
    if (_ttv == null) {
        _ttv = new TreeTableView<FormItem<?>>(
                new FormTreeItem(this, null, _rootItem));
        _ttv.getRoot().setExpanded(true);
        _ttv.setShowRoot(false);

        TreeTableColumn<FormItem<?>, String> nameColumn = new TreeTableColumn<FormItem<?>, String>(
                "Name");
        nameColumn.setPrefWidth(250);
        nameColumn.setCellValueFactory(param -> {
            String displayName = param.getValue().getValue().displayName();
            return new ReadOnlyStringWrapper(displayName);
        });
        nameColumn.setStyle("-fx-font-weight: bold;");

        TreeTableColumn<FormItem<?>, FormItem<?>> valueColumn = new TreeTableColumn<FormItem<?>, FormItem<?>>(
                "Value");
        valueColumn.setPrefWidth(500);
        valueColumn.setCellValueFactory(param -> {
            return param.getValue().valueProperty();
        });
        valueColumn.setCellFactory(column -> {
            return new FormTreeTableCell();
        });
        _ttv.getColumns().add(nameColumn);
        _ttv.getColumns().add(valueColumn);
        _stackPane.getChildren().setAll(_ttv);

        FormTreeItem rootTreeItem = (FormTreeItem) _ttv.getRoot();
        ObservableList<FormItem<?>> items = _rootItem.getItems();
        if (items != null) {
            for (FormItem<?> item : items) {
                addTreeItem(rootTreeItem, item);
            }
        }
    }
}
 
开发者ID:uom-daris,项目名称:daris,代码行数:39,代码来源:Form.java

示例7: start

import javafx.scene.control.TreeTableColumn; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
    final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);

    TreeTableColumn<Person, String> numberCol = new TreeTableColumn<>("#");
    numberCol.setCellValueFactory(p -> p.getValue().getValue().hierarchyProperty());
    numberCol.setPrefWidth(100);
    numberCol.setCellFactory(TextFieldTreeTableCell.<Person>forTreeTableColumn());

    TreeTableColumn<Person, String> firstNameCol = new TreeTableColumn<>("First Name");
    firstNameCol.setPrefWidth(150);
    firstNameCol.setEditable(true);
    firstNameCol.setCellValueFactory(p -> p.getValue().getValue().firstNameProperty());
    firstNameCol.setCellFactory(TextFieldTreeTableCell.<Person>forTreeTableColumn());

    TreeTableColumn<Person, String> lastNameCol = new TreeTableColumn<>("Last Name");
    lastNameCol.setPrefWidth(150);
    lastNameCol.setEditable(true);
    lastNameCol.setCellValueFactory(p -> p.getValue().getValue().lastNameProperty());
    lastNameCol.setCellFactory(TextFieldTreeTableCell.<Person>forTreeTableColumn());

    TreeTableColumn<Person, Date> birthdayCol = new TreeTableColumn<>("Birthday");
    birthdayCol.setPrefWidth(250);
    birthdayCol.setCellValueFactory(p -> p.getValue().getValue().birthdayProperty());
    birthdayCol.setEditable(false);
    birthdayCol.setCellFactory(TextFieldTreeTableCell.<Person, Date>forTreeTableColumn(new StringConverter<Date>() {
        @Override
        public String toString(Date t) {
            return df.format(t);
        }

        @Override
        public Date fromString(String string) {
            try {
                return df.parse(string);
            } catch (ParseException ex) {
                return null;
            }
        }
    }));

    final TreeTableView<Person> treeTableView = new TreeTableView<Person>();
    treeTableView.setEditable(true);
    treeTableView.setId(TREE_TABLE_VIEW_ID);
    treeTableView.setRoot(new TreeItem(new Person("0", "Root", "Root", new Date(r.nextLong() % 946080000000L))));
    addContent(treeTableView.getRoot(), 2, 4, "0");
    treeTableView.getColumns().setAll(numberCol, firstNameCol, lastNameCol, birthdayCol);
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    treeTableView.getSelectionModel().setCellSelectionEnabled(true);
    treeTableView.getSelectionModel().select(5, numberCol);

    VBox vBox = new VBox();
    vBox.getChildren().setAll(treeTableView);

    Scene scene = new Scene(vBox, 800, 500);

    stage.setScene(scene);
    stage.show();
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:60,代码来源:TreeTableViewApp.java


注:本文中的javafx.scene.control.TreeTableColumn.setPrefWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。