当前位置: 首页>>代码示例>>Java>>正文


Java FXCollections.observableList方法代码示例

本文整理汇总了Java中javafx.collections.FXCollections.observableList方法的典型用法代码示例。如果您正苦于以下问题:Java FXCollections.observableList方法的具体用法?Java FXCollections.observableList怎么用?Java FXCollections.observableList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.collections.FXCollections的用法示例。


在下文中一共展示了FXCollections.observableList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStudentCountByOccupation

import javafx.collections.FXCollections; //导入方法依赖的package包/类
private PieChart getStudentCountByOccupation(
	List<Student> students,
	Function<Student, String> classifier
){
	Map<String, Long> occupationBreakUp = 
       	students.stream().collect(
   			Collectors.groupingBy(
   				classifier,
   				Collectors.counting()
   			)
   		);
       List<PieChart.Data> pieChartData = 
       	new ArrayList<>();

       occupationBreakUp.forEach((k, v) -> {
       	pieChartData.add(new PieChart.Data(k.toString(), v));
       });

       PieChart chart = new PieChart(
       	FXCollections.observableList(pieChartData)
       );
       return chart;
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Cookbook,代码行数:24,代码来源:PieChartDemo.java

示例2: initialize

import javafx.collections.FXCollections; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void initialize(URL location, ResourceBundle resources) {
    // Initializes test base, tester and test map to access and modify the algorithm base
    testBase = TestBase.INSTANCE;   // Gets a reference to the test base
    tester = new Tester();          //
    testMap = tester.getTestMap();

    // Binds the list view with a list of algorithms (list items)
    listItems = FXCollections.observableList(new ArrayList<>(testMap.keySet()));
    list.itemsProperty().bindBidirectional(new SimpleListProperty<>(listItems));
    list.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    list.getSelectionModel().selectedItemProperty().addListener((((observable, oldValue, newValue) -> {
        if(newValue != null) {
            textArea.setText(testMap.get(newValue).getContent());
        } else {
            textArea.clear();
        }
    })));
    list.getSelectionModel().select(0);

    // Initializes the trie that stores all algorithm names
    algorithmNameTrie = new Trie();
    for(String algorithmName : testMap.keySet()) {
        algorithmNameTrie.addWord(algorithmName);
    }

    // Binds search field with the list view (displays search result)
    searchField.textProperty().addListener((observable, oldValue, newValue) -> {
        listItems.setAll(algorithmNameTrie.getWords(newValue.toLowerCase()));
        if(!listItems.isEmpty()) {
            list.getSelectionModel().select(0);
        }
    });

    // For unknown reasons, this style does not work on css, so I put it in here
    textArea.setStyle("-fx-focus-color: transparent; -fx-text-box-border: transparent;");
    textArea.setFocusTraversable(false);
}
 
开发者ID:kinmanlui,项目名称:code-tracker,代码行数:40,代码来源:MainController.java

示例3: testNestedRows

import javafx.collections.FXCollections; //导入方法依赖的package包/类
@Test
public void testNestedRows() {
  ObservableList<SpecificationRow<StringProperty>> rows =
      FXCollections.observableList(
          Collections.singletonList(specRow),
          identityExtractor()
      );
  rows.addListener((Observable obs) -> listenerCalls++);

  assertEquals("listener calls before change", 0, listenerCalls);
  toBeChanged.set("XXX");
  assertEquals("listener calls after change", 1, listenerCalls);

  StringProperty toBeAddedChangedRemoved = new SimpleStringProperty("");

  rows.get(0).getCells().put("toBeAddedChangedRemoved", toBeAddedChangedRemoved);
  assertEquals("listener calls after adding", 2, listenerCalls);

  toBeAddedChangedRemoved.set("ASDF");
  assertEquals("listener calls after changing added", 3, listenerCalls);

  rows.get(0).getCells().remove("toBeAddedChangedRemoved");
  assertEquals("listener calls after removing", 4, listenerCalls);

  toBeAddedChangedRemoved.set("SHOULD NOT FIRE EVENT");
  assertEquals("listener calls after changing cell that was removed", 4, listenerCalls);
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:28,代码来源:SpecificationRowTest.java

示例4: MethodDisplay

import javafx.collections.FXCollections; //导入方法依赖的package包/类
private MethodDisplay() {
	this.setVisibleRowCount(ROW_COUNT);
	this.setPromptText("Available commands");

	List<String> dumMethods = new ArrayList<>();
	methods = FXCollections.observableList(dumMethods);
	//updateMethods();
	this.setItems(methods);
	this.getSelectionModel().selectedIndexProperty().addListener((observableValue,oldVal,newVal)->{
			SingleEventHandler.this.addScript(getSelectionModel().getSelectedItem());	
		});
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:13,代码来源:EventHandlerPane.java

示例5: bind

import javafx.collections.FXCollections; //导入方法依赖的package包/类
@Test
public void bind() throws Exception {
    ObservableList<String> origList = RxCollections.of(new ArrayList<>());
    javafx.collections.ObservableList<String> fxList = FXCollections.observableList(new ArrayList<>());
    Disposable listBinding = RxCollectionsFX.bind(origList, fxList);
    String str = "Hello world!";
    origList.add(str);
    assertEquals(fxList.get(0), str);
    listBinding.dispose();
}
 
开发者ID:FHannes,项目名称:RxJavaCollections,代码行数:11,代码来源:RxCollectionsFXTest.java

示例6: DeveloperData

import javafx.collections.FXCollections; //导入方法依赖的package包/类
public DeveloperData() {
	List<SpriteMakerModel> list=new ArrayList<SpriteMakerModel>();
	levelData = FXCollections.observableArrayList();
	mySprites=FXCollections.observableList(list);
	sprites=new SpritesForScreenUse();
	List<Path> dummyPaths=new ArrayList<>();
	myPaths=FXCollections.observableList(dummyPaths);
	myPaths.add(new Path());
	myData.put(LEVEL_COMPLETION_BONUS, "");
	myData.put(NUMBER_OF_STARTING_GOLD, "");	
	myData.put(BUILD_TOWER, "false");
	myData.put(NUMBER_OF_LIVES, "");
	myData.put(GAME_NAME, "");
	myData.put(GAME_ICON, "");
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:16,代码来源:DeveloperData.java

示例7: PowerMizerPane

import javafx.collections.FXCollections; //导入方法依赖的package包/类
public PowerMizerPane()
{
    super();
    
    table = new TableView<>(FXCollections.observableList(InstanceProvider.getPerformanceLevels()));
    table.setMinHeight(125);
    table.setMaxHeight(125);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setEditable(false);
    
    perfLevel = new TableColumn<>("Performance Level");
    perfLevel.setCellValueFactory(new PropertyValueFactory("name"));
    perfLevel.setSortable(false);
    
    minClock = new TableColumn<>("Min Core(MHz)");
    minClock.setCellValueFactory(new PropertyValueFactory("minCore"));
    minClock.setSortable(false);
    
    maxClock = new TableColumn<>("Max Core(MHz)");
    maxClock.setCellValueFactory(new PropertyValueFactory("maxCore"));
    maxClock.setSortable(false);
    
    minMemory = new TableColumn<>("Min Memory(MHz)");
    minMemory.setCellValueFactory(new PropertyValueFactory("minMemory"));
    minMemory.setSortable(false);
    
    maxMemory = new TableColumn<>("Max Memory(MHz)");
    maxMemory.setCellValueFactory(new PropertyValueFactory("maxMemory"));
    maxMemory.setSortable(false);
    
    table.getColumns().addAll(perfLevel, minClock, maxClock, minMemory, maxMemory);
    
    performancePane = new PerformanceModePane();
    
    super.getChildren().addAll(table, performancePane);
}
 
开发者ID:BlueGoliath,项目名称:Goliath-Overclocking-Utility-FX,代码行数:37,代码来源:PowerMizerPane.java

示例8: getVars

import javafx.collections.FXCollections; //导入方法依赖的package包/类
public ObservableList<Var> getVars() {
    if (backend.getStepDefs() == null) {
        return FXCollections.emptyObservableList();
    }
    ScriptValueMap map = backend.getStepDefs().getContext().getVars();
    List<Var> list = new ArrayList(map.size());
    for (Map.Entry<String, ScriptValue> entry : map.entrySet()) {
        list.add(new Var(entry.getKey(), entry.getValue()));
    }
    return FXCollections.observableList(list);
}
 
开发者ID:intuit,项目名称:karate,代码行数:12,代码来源:AppSession.java

示例9: FreeVariableList

import javafx.collections.FXCollections; //导入方法依赖的package包/类
/**
 * Copy constructor for deep copies of a {@link FreeVariableList}.
 *
 * @param freeVariableList the list to copy
 */
public FreeVariableList(FreeVariableList freeVariableList) {
  List<FreeVariable> clonedVariables = new ArrayList<>();
  for (FreeVariable freeVar : freeVariableList.getVariables()) {
    clonedVariables.add(new FreeVariable(freeVar));
  }
  this.variables = FXCollections.observableList(clonedVariables, FreeVariable.EXTRACTOR);
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:13,代码来源:FreeVariableList.java

示例10: create

import javafx.collections.FXCollections; //导入方法依赖的package包/类
public static <T extends Enum<T>> ComboBox<T> create(Class<T> enumType, T defaultEnumValue) {

        List<T> entries = new ArrayList<>();
        Collections.addAll(entries, enumType.getEnumConstants());

        ObservableList<T> observableList = FXCollections.observableList(entries);
        ComboBox<T> comboBox = new ComboBox<T>(observableList);
        comboBox.setValue(defaultEnumValue);

        return comboBox;
    }
 
开发者ID:schibsted,项目名称:strongbox,代码行数:12,代码来源:EnumComboBox.java

示例11: init

import javafx.collections.FXCollections; //导入方法依赖的package包/类
private void init() {
	setHgap(4 * GuiConstants.padding);
	setVgap(4 * GuiConstants.padding);

	ColumnConstraints colConstraint = new ColumnConstraints();
	colConstraint.setPercentWidth(50);
	getColumnConstraints().addAll(colConstraint, colConstraint);

	RowConstraints rowConstraintInput = new RowConstraints();
	RowConstraints rowConstraintClassPath = new RowConstraints();
	rowConstraintClassPath.setVgrow(Priority.SOMETIMES);
	RowConstraints rowConstraintButtons = new RowConstraints();
	RowConstraints rowConstraintShared = new RowConstraints();
	rowConstraintShared.setVgrow(Priority.SOMETIMES);
	getRowConstraints().addAll(rowConstraintInput, rowConstraintClassPath, rowConstraintButtons, rowConstraintShared);

	ObservableList<Path> pathsA = FXCollections.observableList(config.getPathsA());
	ObservableList<Path> pathsB = FXCollections.observableList(config.getPathsB());
	classPathA = FXCollections.observableList(config.getClassPathA());
	classPathB = FXCollections.observableList(config.getClassPathB());
	sharedClassPath = FXCollections.observableList(config.getSharedClassPath());

	add(createFilesSelectionPane("Inputs A", pathsA, window, false, false), 0, 0);
	add(createFilesSelectionPane("Inputs B", pathsB, window, false, false), 1, 0);
	add(createFilesSelectionPane("Class path A", classPathA, window, true, false), 0, 1);
	add(createFilesSelectionPane("Class path B", classPathB, window, true, false), 1, 1);

	HBox hbox = new HBox(GuiConstants.padding);
	Button swapButton = new Button("swap A ⇄ B");
	hbox.getChildren().add(swapButton);
	swapButton.setOnAction(event -> {
		List<Path> paths = new ArrayList<>(pathsA);
		pathsA.clear();
		pathsA.addAll(pathsB);
		pathsB.setAll(paths);

		paths.clear();
		paths.addAll(classPathA);
		classPathA.clear();
		classPathA.addAll(classPathB);
		classPathB.setAll(paths);
	});
	add(hbox, 0, 2, 2, 1);

	add(createFilesSelectionPane("Shared class path", sharedClassPath, window, true, true), 0, 3, 2, 1);
	// TODO: config.inputsBeforeClassPath

	ListChangeListener<Path> listChangeListener = change -> okButton.setDisable(!config.isValid());

	pathsA.addListener(listChangeListener);
	pathsB.addListener(listChangeListener);
	classPathA.addListener(listChangeListener);
	classPathB.addListener(listChangeListener);
	sharedClassPath.addListener(listChangeListener);
	listChangeListener.onChanged(null);
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:57,代码来源:NewProjectPane.java

示例12: init

import javafx.collections.FXCollections; //导入方法依赖的package包/类
private void init() {
	getChildren().add(new Label("Input directories:"));

	ListView<Path> list = new ListView<>(FXCollections.observableList(paths));
	getChildren().add(list);

	list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	list.setPrefWidth(320);
	list.setPrefHeight(200);
	VBox.setVgrow(list, Priority.ALWAYS);

	HBox footer = new HBox(GuiConstants.padding);
	getChildren().add(footer);

	footer.setAlignment(Pos.CENTER_RIGHT);

	Button button = new Button("add");
	footer.getChildren().add(button);
	button.setOnAction(event -> {
		Path path = Gui.requestDir("Select directory to add", window);
		if (path != null && !list.getItems().contains(path)) list.getItems().add(path);
	});

	Button removeButton = new Button("remove");
	footer.getChildren().add(removeButton);
	removeButton.setOnAction(event -> {
		Set<Path> selected = new HashSet<>(list.getSelectionModel().getSelectedItems());
		list.getItems().removeIf(selected::contains);
	});

	ListChangeListener<Path> itemChangeListener = change -> {
		okButton.setDisable(paths.isEmpty());
	};

	list.getItems().addListener(itemChangeListener);

	ListChangeListener<Path> selectChangeListener = change -> {
		List<Integer> selectedIndices = list.getSelectionModel().getSelectedIndices();
		boolean empty = selectedIndices.isEmpty();

		removeButton.setDisable(empty);
	};

	list.getSelectionModel().getSelectedItems().addListener(selectChangeListener);

	itemChangeListener.onChanged(null);
	selectChangeListener.onChanged(null);
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:49,代码来源:LoadProjectPane.java

示例13: init

import javafx.collections.FXCollections; //导入方法依赖的package包/类
private void init (String key, List<StringProperty> values) {
    myKey = key;
    myValues = FXCollections.observableList(values);
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:5,代码来源:FormData.java

示例14: setCatalogue

import javafx.collections.FXCollections; //导入方法依赖的package包/类
public void setCatalogue(Catalogue catalogue) {
    LOGGER.debug("Setting catalogue %s", catalogue);
    this.catalogue = catalogue;
    this.catalogue.resyncRequirements();
    observableRequirements = FXCollections.observableList(catalogue.requirementList());
    observableMilestones = FXCollections.observableList(catalogue.milestoneList());
    lastOrdinal = catalogue.getLastOrdinal();

    maxSumProperty.set(catalogue.getSum());

    observableRequirements.addListener(new ListChangeListener<Requirement>() {
        @Override
        public void onChanged(Change<? extends Requirement> c) {
            LOGGER.traceEntry();
            while (c.next()) {
                if (c.wasPermutated()) {
                    // Permutation
                    for (int i = c.getFrom(); i < c.getTo(); ++i) {

                    }
                } else if (c.wasUpdated()) {
                    // Update
                    LOGGER.error("UPDATED"); // TODO Handle
                } else {
                    for (Requirement removeItem : c.getRemoved()) {
                        if (removeItem == null) {
                            continue;
                        }
                        double sumPre = catalogue.getSum();
                        double change = removeItem.getMaxPoints();
                        double sumPost = sumPre - change;
                        LOGGER.trace(String.format(":onChanged - Remove: pre:%g, change:%g, post%g", sumPre, change, sumPost));
                        maxSumProperty.set(catalogue.getSum() - removeItem.getMaxPoints());
                    }
                    for (Requirement addItem : c.getAddedSubList()) {
                        if (addItem == null) {
                            continue;
                        }
                        maxSumProperty.set(catalogue.getSum() + addItem.getMaxPoints());
                    }
                }

            }
            c.reset();
        }
    });
}
 
开发者ID:dbisUnibas,项目名称:ReqMan,代码行数:48,代码来源:EntityManager.java

示例15: populateDDL

import javafx.collections.FXCollections; //导入方法依赖的package包/类
private static void populateDDL(ChoiceBox<String> dropDownList, Collection<String> items) {
    List<String> list = new ArrayList<>(items);
    ObservableList<String> dropDownItems = FXCollections.observableList(list);
    dropDownList.setItems(dropDownItems);
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:6,代码来源:AdvancedOptionsController.java


注:本文中的javafx.collections.FXCollections.observableList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。