本文整理匯總了Java中javafx.scene.control.ListView.setPrefHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.setPrefHeight方法的具體用法?Java ListView.setPrefHeight怎麽用?Java ListView.setPrefHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.ListView
的用法示例。
在下文中一共展示了ListView.setPrefHeight方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: list
import javafx.scene.control.ListView; //導入方法依賴的package包/類
private ListView<String> list() {
ListView<String> tables = new ListView<>(FXCollections.observableArrayList());
tables.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
tables.setPrefHeight(480);
tables.setPrefWidth(256);
return tables;
}
示例2: init
import javafx.scene.control.ListView; //導入方法依賴的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);
}