當前位置: 首頁>>代碼示例>>Java>>正文


Java ObservableList類代碼示例

本文整理匯總了Java中javafx.collections.ObservableList的典型用法代碼示例。如果您正苦於以下問題:Java ObservableList類的具體用法?Java ObservableList怎麽用?Java ObservableList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObservableList類屬於javafx.collections包,在下文中一共展示了ObservableList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refreshListView

import javafx.collections.ObservableList; //導入依賴的package包/類
protected void refreshListView () {

        this.questionList.getItems().clear();

        //create list with all questions
        ObservableList<String> questions = FXCollections.observableArrayList();

        //iterate through all questions
        for (Map.Entry<String,QuestionEntry> entry : this.questionMap.entrySet()) {
            //add question name to list
            questions.add(entry.getKey());
        }

        Collections.sort(questions);

        if (questions.size() <= 0) {
            //hide delete button
            this.deleteButton.setVisible(false);
        } else {
            //show delete button
            this.deleteButton.setVisible(true);
        }

        this.questionList.setItems(questions);
    }
 
開發者ID:leeks-and-dragons,項目名稱:dialog-tool,代碼行數:26,代碼來源:MainWindowController.java

示例2: setValue

import javafx.collections.ObservableList; //導入依賴的package包/類
/**
 * 裝載麵板數據.
 *
 * @param key 數據庫中的鍵
 */
@Override
public void setValue(String key) {
    ObservableList<TableEntity> values = FXCollections.observableArrayList();
    Set<String> sets = redisSet.getMembersSet(key);
    int i = 0;
    for (String set : sets) {
        TableEntity value = new TableEntity("" + i, key, set);
        values.add(value);
        i++;
    }
    this.dataTable.setItems(values);
    this.rowColumn.setCellValueFactory(cellData -> cellData.getValue().rowProperty());
    this.keyColumn.setCellValueFactory(cellData -> cellData.getValue().keyProperty());
    this.valueColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
}
 
開發者ID:Kuangcp,項目名稱:MythRedisClient,代碼行數:21,代碼來源:SetAction.java

示例3: CollatedTreeItem

import javafx.collections.ObservableList; //導入依賴的package包/類
public CollatedTreeItem() {
    children = FXCollections.observableArrayList();
    filteredChildren = new FilteredList<>(children, new Predicate<TreeItem<T>>() {
        @Override public boolean test(TreeItem<T> t) {
            return filter.test(t.getValue());
        }
    });
    sortedChildren = new SortedList<>(filteredChildren);
    ObservableList<TreeItem<T>> original = super.getChildren();
    sortedChildren.addListener(new ListChangeListener<TreeItem<T>>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<T>> c) {
            while (c.next()) {
                original.removeAll(c.getRemoved());
                original.addAll(c.getFrom(), c.getAddedSubList());
            }
        }
    });
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:CollatedTreeItem.java

示例4: instantiateSelector

import javafx.collections.ObservableList; //導入依賴的package包/類
private ComponentSelectorPane instantiateSelector() {
	List<Class<? extends Component>> basicComponents = new ArrayList<>();
	ObservableList<Class<? extends Component>> observableComponents = FXCollections.observableList(basicComponents);
	observableComponents.add(Cost.class);
	observableComponents.add(Attacker.class);
	observableComponents.add(Collidable.class);
	observableComponents.add(Health.class);
	observableComponents.add(Images.class);
	observableComponents.add(Owner.class);
	observableComponents.add(PathFollower.class);
	observableComponents.add(Range.class);
	observableComponents.add(RangeShootingAI.class);
	observableComponents.add(Selectable.class);
	observableComponents.add(SoundEffect.class);
	observableComponents.add(Speed.class);
	observableComponents.add(SkillSet.class);
	observableComponents.add(TowerDefenceTypeInformation.class);
	observableComponents.add(Upgrade.class);

	return new ComponentSelectorPane(myResources.getString("addComponents"), observableComponents, infoPane);
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:22,代碼來源:SpriteCreationScreen.java

示例5: convertPaymentArrayListToObservableList

import javafx.collections.ObservableList; //導入依賴的package包/類
public ObservableList<TableRowDataModel> convertPaymentArrayListToObservableList(ArrayList Payments) {
    ObservableList<TableRowDataModel> tempList = FXCollections.observableArrayList();
    for (Object dateAndPrice : Payments) {
        String oldstring = (String) ((Pair) dateAndPrice).getKey();
        try {
            Date old = new SimpleDateFormat("yyyy-MM-dd").parse(oldstring);
            String newstring = new SimpleDateFormat("yyyy년MM월dd일").format(old);

        SimpleStringProperty date = new SimpleStringProperty(newstring);
        int price = (int) ((Pair) dateAndPrice).getValue();
        tempList.add(new TableRowDataModel(date, new SimpleStringProperty(price + "원")));
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    return tempList;
}
 
開發者ID:Jinsu-L,項目名稱:CNU_TermProject_SoftwareEngineering,代碼行數:18,代碼來源:SalesStatusController.java

示例6: droppedOnTreeItem

import javafx.collections.ObservableList; //導入依賴的package包/類
private void droppedOnTreeItem(DragEvent event,
		TreeItem<LayerBaseContainer<? extends LayerBase>> currentlyDraggedLayerTreeItem,
		LayerBaseContainer<? extends LayerBase> targetItem) {
	LayerBase targetLayer = targetItem.getLayerBase();

	double y = event.getY();
	double height = getHeight();
	boolean above = y < height / 2;

	TreeItem<LayerBaseContainer<? extends LayerBase>> targetParent = this.getTreeItem().getParent();
	ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> targetParentChildren = targetParent
			.getChildren();

	TreeItem<LayerBaseContainer<? extends LayerBase>> draggedItem = currentlyDraggedLayerTreeItem;
	TreeItem<LayerBaseContainer<? extends LayerBase>> draggedParent = draggedItem.getParent();
	ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> draggedParentChildren = draggedParent != null
			? draggedParent.getChildren() : null;

	if (targetLayer instanceof EffectGroupLayer && (y >= height / 4 && y < height * 3 / 4)) {
		// inside group
		ObservableList<TreeItem<LayerBaseContainer<? extends LayerBase>>> groupChildren = getTreeItem()
				.getChildren();
		if (!groupChildren.equals(draggedParentChildren)) {
			if (draggedParentChildren != null) {
				draggedParentChildren.remove(draggedItem);
			}
			DelayedExecuter.execute(100, () -> groupChildren.add(0, draggedItem));
		}
	} else {
		if (draggedParentChildren != null) {
			ListItemUtil.swapItemsJavaFxThread(draggedParentChildren, targetParentChildren, draggedItem, this.getTreeItem(),
					above);
		} else {
			ListItemUtil.insertItem(targetParentChildren, draggedItem, this.getTreeItem(), above);
		}
	}
}
 
開發者ID:enoy19,項目名稱:keyboard-light-composer,代碼行數:38,代碼來源:LayerBaseTreeCell.java

示例7: fill

import javafx.collections.ObservableList; //導入依賴的package包/類
/**
 * Fill the tree item.
 *
 * @param item the tree item.
 */
@FXThread
private void fill(@NotNull final TreeItem<VirtualResourceElement<?>> item) {

    final VirtualResourceElement<?> element = item.getValue();
    if(!element.hasChildren()) {
        return;
    }

    final ObservableList<TreeItem<VirtualResourceElement<?>>> items = item.getChildren();

    final Array<VirtualResourceElement<?>> children = element.getChildren();
    children.sort(NAME_COMPARATOR);
    children.forEach(child -> items.add(new TreeItem<>(child)));

    items.forEach(this::fill);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:VirtualResourceTree.java

示例8: buildChildren

import javafx.collections.ObservableList; //導入依賴的package包/類
@SneakyThrows(IOException.class)
private ObservableList<TreeItem<Path>> buildChildren() {
    if (Files.isDirectory(getValue())) {
        return Files.list(getValue())
                .map(e -> {
                    WatcherStructure watcherStructure = null;
                    if (Files.isDirectory(e)) {
                        watcherStructure = new WatcherStructure(e, project, tabUpdater, treeUpdater);
                    }

                    CustomTreeItem item = new CustomTreeItem(e, watcherStructure, project, tabUpdater, treeUpdater);

                    CustomIcons customIcons = new CustomIcons();
                    item.setGraphic(new ImageView(item.isDirectory() ? customIcons.getFolderCollapseImage() : customIcons.getFileImage()));
                    if (isDirectory()) {
                        item.expandedProperty().addListener(treeUpdater.expanderListener());
                    }

                    return item;
                })
                .collect(Collectors.toCollection(FXCollections::observableArrayList));
    }

    return FXCollections.emptyObservableList();
}
 
開發者ID:MrChebik,項目名稱:Coconut-IDE,代碼行數:26,代碼來源:CustomTreeItem.java

示例9: fillContextMenu

import javafx.collections.ObservableList; //導入依賴的package包/類
@Override
@FXThread
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree,
                            @NotNull final ObservableList<MenuItem> items) {
    if (!(nodeTree instanceof ModelNodeTree)) return;

    final T element = getElement();
    final AssetLinkNode linkNode = findParent(element, AssetLinkNode.class::isInstance);

    if (linkNode == null) {
        final Menu createMenu = createCreationMenu(nodeTree);
        if (createMenu != null) items.add(createMenu);
        final Menu toolMenu = createToolMenu(nodeTree);
        if (toolMenu != null) items.add(toolMenu);
    }

    if (linkNode == null || element == linkNode) {
        items.add(new AddUserDataAction(nodeTree, this));
    }

    if (canRemove()) {
        items.add(new RemoveNodeAction(nodeTree, this));
    }

    super.fillContextMenu(nodeTree, items);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:SpatialTreeNode.java

示例10: populateMenuItems

import javafx.collections.ObservableList; //導入依賴的package包/類
private void populateMenuItems(ContextMenu contextMenu, Tab tab) {
    int tabCount = getTabs().size();
    int tabIndex = getTabs().indexOf(tab);
    ObservableList<MenuItem> items = contextMenu.getItems();
    items.clear();
    MenuItem closeMenuItem = new MenuItem("Close");
    closeMenuItem.setOnAction((e) -> requestClose(tab));
    items.add(closeMenuItem);
    if (tabCount > 1) {
        MenuItem closeRestMenuItem = new MenuItem("Close Others");
        closeRestMenuItem.setOnAction((e) -> closeOtherTabs(tab));
        items.add(closeRestMenuItem);
    }
    if (tabCount > 1 && tabIndex != 0) {
        MenuItem closeLeftTabsMenuItem = new MenuItem("Close Tabs to the Left");
        closeLeftTabsMenuItem.setOnAction((e) -> closeTabsToLeft(tab));
        items.add(closeLeftTabsMenuItem);
    }
    if (tabCount > 1 && tabIndex != tabCount - 1) {
        MenuItem closeRigthTabsMenuItem = new MenuItem("Close Tabs to the Right");
        closeRigthTabsMenuItem.setOnAction((e) -> closeTabsToRight(tab));
        items.add(closeRigthTabsMenuItem);
    }
    if (tabCount > 1) {
        MenuItem closeAllMenuItem = new MenuItem("Close All");
        closeAllMenuItem.setOnAction((e) -> closeAllTabs());
        items.addAll(new SeparatorMenuItem(), closeAllMenuItem);
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:30,代碼來源:TabDockingContainer.java

示例11: deepCopySeriesData

import javafx.collections.ObservableList; //導入依賴的package包/類
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
        final Collection<? extends XYChart.Data<X, Y>> data) {
    final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
    for (final Data<X, Y> i : data) {
        result.add(new Data<>(i.getXValue(), i.getYValue()));
    }
    return result;
}
 
開發者ID:gransort,項目名稱:Java-oscilloscope-project,代碼行數:9,代碼來源:ZoomManager.java

示例12: getChildren

import javafx.collections.ObservableList; //導入依賴的package包/類
private ObservableList<Node> getChildren(Node node) {
    if (node instanceof ButtonBar) {
        return ((ButtonBar) node).getButtons();
    }
    if (node instanceof ToolBar) {
        return ((ToolBar) node).getItems();
    }
    if (node instanceof Pane) {
        return ((Pane) node).getChildren();
    }
    if (node instanceof TabPane) {
        ObservableList<Node> contents = FXCollections.observableArrayList();
        ObservableList<Tab> tabs = ((TabPane) node).getTabs();
        for (Tab tab : tabs) {
            contents.add(tab.getContent());
        }
        return contents;
    }
    return FXCollections.observableArrayList();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:21,代碼來源:ModalDialog.java

示例13: PathSetter

import javafx.collections.ObservableList; //導入依賴的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);
	
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:18,代碼來源:PathSetter.java

示例14: testFindAllTermsWithTitle

import javafx.collections.ObservableList; //導入依賴的package包/類
@Test
public void testFindAllTermsWithTitle() {
    LoggerFacade.getDefault().own(SqlProviderTest.class, "testFindAllTermsWithTitle()"); // NOI18N
    
    // ---------------------------------------------------------------------
    try { Thread.sleep(15); } catch (InterruptedException e) { }
    
    Term term1 = ModelProvider.getDefault().getTerm("Term1");
    SqlProvider.getDefault().createTerm(term1);
    
    ObservableList<Term> terms = FXCollections.observableArrayList();
    terms.addAll(SqlProvider.getDefault().findAllTermsWithTitle("hello?"));
    assertTrue(terms.isEmpty());
    
    terms.clear();
    terms.addAll(SqlProvider.getDefault().findAllTermsWithTitle("Term1"));
    assertFalse(terms.isEmpty());
    assertTrue(terms.size() == 1);
    assertEquals("Term1", terms.get(0).getTitle());
    
    // ---------------------------------------------------------------------
    DatabaseFacade.getDefault()
            .getCrudService("testFindAllTerms()")
            .delete(Term.class, term1.getId());
}
 
開發者ID:Naoghuman,項目名稱:ABC-List,代碼行數:26,代碼來源:SqlProviderTest.java

示例15: getValidWindows

import javafx.collections.ObservableList; //導入依賴的package包/類
private Stage[] getValidWindows() {
    ObservableList<Stage> stages = StageHelper.getStages();
    List<Stage> valid = new ArrayList<Stage>();
    for (Stage window : stages) {
        if (window.isShowing()) {
            valid.add(window);
        }
    }
    return valid.toArray(new Stage[valid.size()]);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:JavaFXTargetLocator.java


注:本文中的javafx.collections.ObservableList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。