当前位置: 首页>>代码示例>>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;未经允许,请勿转载。