本文整理匯總了Java中javafx.scene.control.ListView.getItems方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.getItems方法的具體用法?Java ListView.getItems怎麽用?Java ListView.getItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.ListView
的用法示例。
在下文中一共展示了ListView.getItems方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: fill
import javafx.scene.control.ListView; //導入方法依賴的package包/類
/**
* Fill a list of app states.
*
* @param sceneNode the scene node
*/
public void fill(@NotNull final SceneNode sceneNode) {
final ListView<EditableSceneAppState> listView = getListView();
final MultipleSelectionModel<EditableSceneAppState> selectionModel = listView.getSelectionModel();
final EditableSceneAppState selected = selectionModel.getSelectedItem();
final ObservableList<EditableSceneAppState> items = listView.getItems();
items.clear();
final List<SceneAppState> appStates = sceneNode.getAppStates();
appStates.stream().filter(EditableSceneAppState.class::isInstance)
.map(EditableSceneAppState.class::cast)
.forEach(items::add);
if (selected != null && appStates.contains(selected)) {
selectionModel.select(selected);
}
}
示例3: selectFirstSuggestion
import javafx.scene.control.ListView; //導入方法依賴的package包/類
private static void selectFirstSuggestion(AutoCompletePopup<?> autoCompletionPopup) {
Skin<?> skin = autoCompletionPopup.getSkin();
if (skin instanceof AutoCompletePopupSkin) {
AutoCompletePopupSkin<?> au = (AutoCompletePopupSkin<?>) skin;
ListView<?> li = (ListView<?>) au.getNode();
if (li.getItems() != null && !li.getItems().isEmpty()) {
li.getSelectionModel().select(0);
}
}
}