本文整理匯總了Java中javafx.scene.control.ListView.setItems方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.setItems方法的具體用法?Java ListView.setItems怎麽用?Java ListView.setItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.ListView
的用法示例。
在下文中一共展示了ListView.setItems方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ComponentSelectorPane
import javafx.scene.control.ListView; //導入方法依賴的package包/類
public ComponentSelectorPane(String listTitle, ObservableList<Class<? extends Component>> displayedData, SpriteDataPane infoPane) {
this.infoPane=infoPane;
this.setPrefWidth(PREF_WIDTH);
ListView<Class<? extends Component>> componentDisplay = new ListView<>();
componentDisplay.setItems(displayedData);
componentDisplay.setCellFactory(
new Callback<ListView<Class<? extends Component>>, ListCell<Class<? extends Component>>>() {
@Override
public ListCell<Class<? extends Component>> call(ListView<Class<? extends Component>> list) {
return new ComponentCustomizerOption();
}
});
Label title = new Label(listTitle);
this.getChildren().addAll(title, componentDisplay);
}
示例2: ListViewCellFactorySample
import javafx.scene.control.ListView; //導入方法依賴的package包/類
public ListViewCellFactorySample() {
final ListView<Number> listView = new ListView<Number>();
listView.setItems(FXCollections.<Number>observableArrayList(
100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
15.00, 47.50, 12.11
));
listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
@Override public ListCell<Number> call(ListView<java.lang.Number> list) {
return new MoneyFormatCell();
}
});
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
getChildren().add(listView);
}
示例3: start
import javafx.scene.control.ListView; //導入方法依賴的package包/類
@Override public void start(Stage primaryStage) throws Exception {
final ListView<String> listView = new ListView<String>();
listView.setItems(FXCollections.observableArrayList("Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6", "Row 7",
"Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13", "Row 14", "Row 15", "Row 16", "Row 17", "Row 18",
"Row 19", "Row 20", "Row 21", "Row 22", "Row 23", "Row 24", "Row 25"));
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
Button button = new Button("Debug");
button.setOnAction((e) -> {
ObservableList<Integer> selectedIndices = listView.getSelectionModel().getSelectedIndices();
for (Integer index : selectedIndices) {
ListCell cellAt = getCellAt(listView, index);
System.out.println("SimpleListViewScrollSample.SimpleListViewScrollSampleApp.start(" + cellAt + ")");
}
});
VBox root = new VBox(listView, button);
primaryStage.setScene(new Scene(root, 300, 400));
primaryStage.show();
}
示例4: buildConfigurationUI
import javafx.scene.control.ListView; //導入方法依賴的package包/類
private Node buildConfigurationUI() {
VBox box = new VBox();
box.setPadding(new Insets(10));
CheckBox cb = new CheckBox(MessageBundle.getInstance().getString("homeTimelineCB"));
cb.selectedProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) -> {
showHomeTimeline = newVal;
});
Label label = new Label(MessageBundle.getInstance().getString("userListLabel") + ":");
ListView<SelectableItem<UserList>> lv = new ListView<>();
lv.setItems(itemList);
lv.setCellFactory(CheckBoxListCell.forListView(item -> item.getSelected()));
VBox.setVgrow(lv, Priority.ALWAYS);
box.getChildren().addAll(cb, label, lv);
showTwitterListSelection();
return box;
}
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:22,代碼來源:TwitterPreferencesController.java
示例5: SimpleListViewSample
import javafx.scene.control.ListView; //導入方法依賴的package包/類
public SimpleListViewSample() {
final ListView<String> listView = new ListView<String>();
listView.setItems(FXCollections.observableArrayList(
"Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6",
"Row 7", "Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13",
"Row 14", "Row 15", "Row 16", "Row 17", "Row 18", "Row 19", "Row 20"
));
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
getChildren().add(listView);
}
示例6: HorizontalListViewSample
import javafx.scene.control.ListView; //導入方法依賴的package包/類
public HorizontalListViewSample() {
ListView horizontalListView = new ListView();
horizontalListView.setOrientation(Orientation.HORIZONTAL);
horizontalListView.setItems(FXCollections.observableArrayList(
"Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6",
"Row 7", "Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13",
"Row 14", "Row 15", "Row 16", "Row 17", "Row 18", "Row 19", "Row 20"
));
getChildren().add(horizontalListView);
}
示例7: TextFieldListViewSample
import javafx.scene.control.ListView; //導入方法依賴的package包/類
public TextFieldListViewSample() {
final ListView<String> listView = new ListView<String>();
listView.setItems(FXCollections.observableArrayList("Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6", "Row 7",
"Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13", "Row 14", "Row 15", "Row 16", "Row 17", "Row 18",
"Row 19", "Row 20"));
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
listView.setEditable(true);
listView.setCellFactory(TextFieldListCell.forListView());
getChildren().add(listView);
}
示例8: SimpleListViewScrollSample
import javafx.scene.control.ListView; //導入方法依賴的package包/類
public SimpleListViewScrollSample() {
final ListView<String> listView = new ListView<String>();
listView.setItems(FXCollections.observableArrayList("Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6", "Row 7",
"Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13", "Row 14", "Row 15", "Row 16", "Row 17", "Row 18",
"Row 19", "Row 20", "Row 21", "Row 22", "Row 23", "Row 24", "Row 25"));
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
getChildren().add(listView);
}
示例9: createSpriteList
import javafx.scene.control.ListView; //導入方法依賴的package包/類
protected ListView<SpriteDefinition> createSpriteList (ObservableList<SpriteDefinition> collection) {
ListView<SpriteDefinition> list = new ListView<SpriteDefinition>();
list.setItems(collection);
list.setCellFactory(c -> getSpriteCellView());
return list;
}