當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。