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


Java ListChangeListener.onChanged方法代码示例

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


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

示例1: init

import javafx.collections.ListChangeListener; //导入方法依赖的package包/类
private void init() {
	setHgap(4 * GuiConstants.padding);
	setVgap(4 * GuiConstants.padding);

	ColumnConstraints colConstraint = new ColumnConstraints();
	colConstraint.setPercentWidth(50);
	getColumnConstraints().addAll(colConstraint, colConstraint);

	RowConstraints rowConstraintInput = new RowConstraints();
	RowConstraints rowConstraintClassPath = new RowConstraints();
	rowConstraintClassPath.setVgrow(Priority.SOMETIMES);
	RowConstraints rowConstraintButtons = new RowConstraints();
	RowConstraints rowConstraintShared = new RowConstraints();
	rowConstraintShared.setVgrow(Priority.SOMETIMES);
	getRowConstraints().addAll(rowConstraintInput, rowConstraintClassPath, rowConstraintButtons, rowConstraintShared);

	ObservableList<Path> pathsA = FXCollections.observableList(config.getPathsA());
	ObservableList<Path> pathsB = FXCollections.observableList(config.getPathsB());
	classPathA = FXCollections.observableList(config.getClassPathA());
	classPathB = FXCollections.observableList(config.getClassPathB());
	sharedClassPath = FXCollections.observableList(config.getSharedClassPath());

	add(createFilesSelectionPane("Inputs A", pathsA, window, false, false), 0, 0);
	add(createFilesSelectionPane("Inputs B", pathsB, window, false, false), 1, 0);
	add(createFilesSelectionPane("Class path A", classPathA, window, true, false), 0, 1);
	add(createFilesSelectionPane("Class path B", classPathB, window, true, false), 1, 1);

	HBox hbox = new HBox(GuiConstants.padding);
	Button swapButton = new Button("swap A ⇄ B");
	hbox.getChildren().add(swapButton);
	swapButton.setOnAction(event -> {
		List<Path> paths = new ArrayList<>(pathsA);
		pathsA.clear();
		pathsA.addAll(pathsB);
		pathsB.setAll(paths);

		paths.clear();
		paths.addAll(classPathA);
		classPathA.clear();
		classPathA.addAll(classPathB);
		classPathB.setAll(paths);
	});
	add(hbox, 0, 2, 2, 1);

	add(createFilesSelectionPane("Shared class path", sharedClassPath, window, true, true), 0, 3, 2, 1);
	// TODO: config.inputsBeforeClassPath

	ListChangeListener<Path> listChangeListener = change -> okButton.setDisable(!config.isValid());

	pathsA.addListener(listChangeListener);
	pathsB.addListener(listChangeListener);
	classPathA.addListener(listChangeListener);
	classPathB.addListener(listChangeListener);
	sharedClassPath.addListener(listChangeListener);
	listChangeListener.onChanged(null);
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:57,代码来源:NewProjectPane.java

示例2: init

import javafx.collections.ListChangeListener; //导入方法依赖的package包/类
private void init() {
	getChildren().add(new Label("Input directories:"));

	ListView<Path> list = new ListView<>(FXCollections.observableList(paths));
	getChildren().add(list);

	list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	list.setPrefWidth(320);
	list.setPrefHeight(200);
	VBox.setVgrow(list, Priority.ALWAYS);

	HBox footer = new HBox(GuiConstants.padding);
	getChildren().add(footer);

	footer.setAlignment(Pos.CENTER_RIGHT);

	Button button = new Button("add");
	footer.getChildren().add(button);
	button.setOnAction(event -> {
		Path path = Gui.requestDir("Select directory to add", window);
		if (path != null && !list.getItems().contains(path)) list.getItems().add(path);
	});

	Button removeButton = new Button("remove");
	footer.getChildren().add(removeButton);
	removeButton.setOnAction(event -> {
		Set<Path> selected = new HashSet<>(list.getSelectionModel().getSelectedItems());
		list.getItems().removeIf(selected::contains);
	});

	ListChangeListener<Path> itemChangeListener = change -> {
		okButton.setDisable(paths.isEmpty());
	};

	list.getItems().addListener(itemChangeListener);

	ListChangeListener<Path> selectChangeListener = change -> {
		List<Integer> selectedIndices = list.getSelectionModel().getSelectedIndices();
		boolean empty = selectedIndices.isEmpty();

		removeButton.setDisable(empty);
	};

	list.getSelectionModel().getSelectedItems().addListener(selectChangeListener);

	itemChangeListener.onChanged(null);
	selectChangeListener.onChanged(null);
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:49,代码来源:LoadProjectPane.java


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