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


Java TableView.setColumnResizePolicy方法代码示例

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


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

示例1: VarsPanel

import javafx.scene.control.TableView; //导入方法依赖的package包/类
public VarsPanel(AppSession session) {
    this.session = session;        
    table = new TableView();
    table.setPrefWidth(300);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    setCenter(table);
    TableColumn nameCol = new TableColumn("Variable");
    nameCol.setMinWidth(120);
    nameCol.setMaxWidth(250);
    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(session.getVars());
    table.setRowFactory(tv -> {
        TableRow<Var> row = new TableRow<>();
        row.setOnMouseClicked(e -> {
            if (e.getClickCount() == 2 && !row.isEmpty()) {
                Var var = row.getItem();
                session.logVar(var);
            }
        });
        return row ;
    });        
}
 
开发者ID:intuit,项目名称:karate,代码行数:32,代码来源:VarsPanel.java

示例2: createClassifierTable

import javafx.scene.control.TableView; //导入方法依赖的package包/类
static <T> TableView<ClassifierResult<T>> createClassifierTable() {
	TableView<ClassifierResult<T>> ret = new TableView<>();
	ret.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

	TableColumn<ClassifierResult<T>, String> tab0 = new TableColumn<>("name");
	tab0.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getClassifier().getName()));
	ret.getColumns().add(tab0);

	TableColumn<ClassifierResult<T>, String> tab1 = new TableColumn<>("score");
	tab1.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(String.format("%.2f", data.getValue().getScore())));
	ret.getColumns().add(tab1);

	TableColumn<ClassifierResult<T>, Double> tab2 = new TableColumn<>("weight");
	tab2.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getClassifier().getWeight()));
	ret.getColumns().add(tab2);

	TableColumn<ClassifierResult<T>, String> tab3 = new TableColumn<>("w. score");
	tab3.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(String.format("%.2f", data.getValue().getScore() * data.getValue().getClassifier().getWeight())));
	ret.getColumns().add(tab3);

	ret.setItems(FXCollections.observableArrayList());

	return ret;
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:25,代码来源:ClassScoresTab.java

示例3: AddMemberDialog

import javafx.scene.control.TableView; //导入方法依赖的package包/类
public AddMemberDialog(Organization organization) {
	super();
	this.organization = organization;
	
	this.setTitle("Add a member");
	this.setHeaderText("Search user");

	ButtonType addButtonType = new ButtonType("Add selected", ButtonData.OK_DONE);
	this.getDialogPane().getButtonTypes().addAll(addButtonType, ButtonType.CANCEL);

	BorderPane mainPane = new BorderPane();
	GridPane queryPane = new GridPane();
	
	queryField = new TextField();
	Button searchButton = new Button("Search");
	searchButton.setOnAction(this::searchAction);
	queryField.setOnAction(this::searchAction);
	searchList = FXCollections.observableArrayList();
	
	TableView<MemberView> searchResult = new TableView<>(searchList);
	searchResult.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
	
	TableColumn<MemberView, String> nameCol = new TableColumn<>("Name");

	nameCol.setCellValueFactory(new PropertyValueFactory<>("username"));

	searchResult.getColumns().add(nameCol);
	
	queryPane.addRow(0, queryField, searchButton);
	queryPane.setHgap(5);
	
	resultCount = new Label();
	
	queryPane.setPadding(new Insets(0, 0, 10, 0));
	resultCount.setPadding(new Insets(10, 0, 0, 0));
	
	mainPane.setTop(queryPane);
	mainPane.setCenter(searchResult);
	mainPane.setBottom(resultCount);
	
	this.getDialogPane().setContent(mainPane);

	this.setResultConverter(dialogButton -> {
		if (dialogButton == addButtonType) {
			Member result = searchResult.selectionModelProperty().get().getSelectedItem().getMember();
			Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to add " + result.getUsername() + " to your organization ?");
			Optional<ButtonType> answer = conf.showAndWait();
			if (answer.isPresent() && answer.get() == ButtonType.OK)
				return result;
			else 
				return null;
		}
		return null;
	});
	
}
 
开发者ID:ScreachFr,项目名称:titanium,代码行数:57,代码来源:AddMemberDialog.java


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