本文整理匯總了Java中javafx.scene.control.ListView類的典型用法代碼示例。如果您正苦於以下問題:Java ListView類的具體用法?Java ListView怎麽用?Java ListView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ListView類屬於javafx.scene.control包,在下文中一共展示了ListView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.scene.control.ListView; //導入依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
VBox root = new VBox();
ListView<String> listView = new ListView<>();
Button refreshButton = new Button("REFRESH");
JavaFxObservable.actionEventsOf(refreshButton)
.observeOn(Schedulers.io())
.flatMapSingle(a ->
Observable.fromArray(getResponse("https://goo.gl/S0xuOi")
.split("\\r?\\n")
).toList()
).observeOn(JavaFxScheduler.platform())
.subscribe(list ->
listView.getItems().setAll(list));
root.getChildren().addAll(listView, refreshButton);
stage.setScene(new Scene(root));
stage.show();
}
示例2: SearchResultViewSkin
import javafx.scene.control.ListView; //導入依賴的package包/類
public SearchResultViewSkin(SearchResultView view) {
super(view);
Label placeholderLabel = new Label();
placeholderLabel.getStyleClass().add("placeholder-label"); //$NON-NLS-1$
listView = new ListView<>();
listView.setItems(view.getSearchResults());
listView.setCellFactory(new SearchResultCellFactory());
listView.setPlaceholder(placeholderLabel);
listView.getSelectionModel().selectedItemProperty()
.addListener(it -> view.getProperties().put(
"selected.search.result", //$NON-NLS-1$
listView.getSelectionModel().getSelectedItem()));
getChildren().add(listView);
}
示例3: call
import javafx.scene.control.ListView; //導入依賴的package包/類
@Override
public ListCell<T> call(ListView<T> list) {
return new ListCell<T>() {
@Override
protected void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setStyle("");
} else {
setText(ListCellFactory.this.getText(item));
setStyle(ListCellFactory.this.getStyle(item));
}
}
};
}
示例4: 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);
}
示例5: initListView
import javafx.scene.control.ListView; //導入依賴的package包/類
private void initListView() {
if (!doesAllowChildren) {
fillUpChildren(fileChooserInfo.getRoot());
}
childrenListView.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
@Override public ListCell<File> call(ListView<File> param) {
return new ChildrenFileCell();
}
});
childrenListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (fileChooserInfo.isFileCreation()) {
return;
}
File selectedItem = childrenListView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
fileNameBox.clear();
}
});
}
示例6: initComponents
import javafx.scene.control.ListView; //導入依賴的package包/類
private void initComponents() {
VBox.setVgrow(historyView, Priority.ALWAYS);
historyView.setItems(FXCollections.observableArrayList(runHistoryInfo.getTests()));
historyView.setCellFactory(new Callback<ListView<JSONObject>, ListCell<JSONObject>>() {
@Override public ListCell<JSONObject> call(ListView<JSONObject> param) {
return new HistoryStateCell();
}
});
VBox historyBox = new VBox(5);
HBox.setHgrow(historyBox, Priority.ALWAYS);
countField.setText(getRemeberedCount());
if (countNeeded) {
form.addFormField("Max count of remembered runs: ", countField);
}
historyBox.getChildren().addAll(new Label("Select test", FXUIUtils.getIcon("params")), historyView, form);
verticalButtonBar.setId("vertical-buttonbar");
historyPane.setId("history-pane");
historyPane.getChildren().addAll(historyBox, verticalButtonBar);
doneButton.setOnAction((e) -> onOK());
buttonBar.setButtonMinWidth(Region.USE_PREF_SIZE);
buttonBar.getButtons().addAll(doneButton);
}
示例7: initCheckList
import javafx.scene.control.ListView; //導入依賴的package包/類
private void initCheckList() {
ToolBar toolBar = new ToolBar();
toolBar.getItems().add(new Text("Check Lists"));
toolBar.setMinWidth(Region.USE_PREF_SIZE);
leftPane.setTop(toolBar);
checkListElements = checkListInfo.getCheckListElements();
checkListView = new ListView<CheckListForm.CheckListElement>(checkListElements);
checkListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
CheckListElement selectedItem = checkListView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
doneButton.setDisable(true);
return;
}
Node checkListForm = getChecklistFormNode(selectedItem, Mode.DISPLAY);
if (checkListForm == null) {
doneButton.setDisable(true);
return;
}
doneButton.setDisable(false);
ScrollPane sp = new ScrollPane(checkListForm);
sp.setFitToWidth(true);
sp.setPadding(new Insets(0, 0, 0, 10));
rightPane.setCenter(sp);
});
leftPane.setCenter(checkListView);
}
示例8: createTableFilter
import javafx.scene.control.ListView; //導入依賴的package包/類
public static SortedList<Ticket> createTableFilter(TextField textSearch, ListView listView){
if(isPrepared)
return new SortedList<>(filteredTickets);
textSearch.setOnKeyPressed((KeyEvent ke) ->{
if(ke.getCode().equals(KeyCode.ENTER)){
text = textSearch.getText();
filterTickets();
}
});
//Listview
listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
categoryText = newValue.split(" ")[0];
if(categoryText.equals("DownloadPlayChild"))
categoryText = "DLP";
filterTickets();
}
});
isPrepared = true;
return new SortedList<>(filteredTickets);
}
示例9: getListItemIndex
import javafx.scene.control.ListView; //導入依賴的package包/類
public int getListItemIndex(ListView<?> listView, String string) {
ObservableList<?> items = listView.getItems();
for (int i = 0; i < items.size(); i++) {
String text = getListSelectionText(listView, i);
if (text.equals(string)) {
return i;
}
}
return -1;
}
示例10: selectForDuplicateItems
import javafx.scene.control.ListView; //導入依賴的package包/類
@Test public void selectForDuplicateItems() {
@SuppressWarnings("unchecked")
ListView<String> listViewNode = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
Platform.runLater(new Runnable() {
@Override public void run() {
listViewNode.getItems().add(2, "Row 2");
}
});
Platform.runLater(() -> listView.marathon_select("[\"Row 2(1)\"]"));
new Wait("Waiting for list item to be select") {
@Override public boolean until() {
return listViewNode.getSelectionModel().getSelectedIndex() == 2;
}
};
}
示例11: selectForMultipleDuplicates
import javafx.scene.control.ListView; //導入依賴的package包/類
@Test public void selectForMultipleDuplicates() {
@SuppressWarnings("unchecked")
ListView<String> listViewNode = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
Platform.runLater(new Runnable() {
@Override public void run() {
listViewNode.getItems().add(2, "Row 2");
listViewNode.getItems().add(9, "Row 2");
listViewNode.getItems().add(10, "Row 2");
}
});
Platform.runLater(() -> listView.marathon_select("[\"Row 2(3)\"]"));
new Wait("Waiting for list item to be select") {
@Override public boolean until() {
return listViewNode.getSelectionModel().getSelectedIndex() == 10;
}
};
}
示例12: onListClick
import javafx.scene.control.ListView; //導入依賴的package包/類
@FXML
public void onListClick(MouseEvent event) {
Scene scene = stage.getScene();
ListView<String> list = (ListView<String>) scene.lookup("#list");
if (list.getSelectionModel() != null && list.getSelectionModel().getSelectedItem() != null) {
JsonObject str = new JsonObject();
str.addProperty("text", list.getSelectionModel().getSelectedItem().replaceAll("\\[.*?\\] @.*? > ", "").replaceAll("\"", "\\\"").trim());
str.addProperty("intent", "precheck");
chatAccess.send(gson.toJson(str));
}
}
示例13: initializeComboBoxTimeChooser
import javafx.scene.control.ListView; //導入依賴的package包/類
private void initializeComboBoxTimeChooser() {
LoggerFacade.getDefault().info(this.getClass(), "Initialize [ComboBox] [TimeChooser]"); // NOI18N
cbTimeChooser.setCellFactory((ListView<ETime> listview) -> new ListCell<ETime>() {
@Override
public void updateItem(ETime time, boolean empty) {
super.updateItem(time, empty);
this.setGraphic(null);
this.setText(!empty ? time.toString() : null);
}
});
final ObservableList<ETime> observableListTimes = FXCollections.observableArrayList();
observableListTimes.addAll(ETime.values());
cbTimeChooser.getItems().addAll(observableListTimes);
cbTimeChooser.getSelectionModel().selectFirst();
}
示例14: 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
示例15: PathSetter
import javafx.scene.control.ListView; //導入依賴的package包/類
public PathSetter(ObservableList<Path> paths, String variableName){
super(Path.class,variableName);
this.myPaths=paths;
pathChoices= new ComboBox<>(myPaths);
pathChoices.setCellFactory(new Callback<ListView<Path>, ListCell<Path>>(){
@Override
public ListCell<Path> call(ListView<Path> list){
return new PathCell();
}
});
pathChoices.setButtonCell(new PathButtonCell());
this.getChildren().add(pathChoices);
}