List of usage examples for javafx.beans.value ChangeListener ChangeListener
ChangeListener
From source file:caillou.company.clonemanager.gui.customComponent.excludeTree.ExcludeTreeController.java
public void buildTreeLazily(final TreeItem<DirectoryLazyCheckableTreeItem> currentItem, int nbPass) { if (nbPass == 0) { return;//from w w w . j a v a2s.c o m } boolean lazyChilds = nbPass > 2; DirectoryLazyCheckableTreeItem currentItemValue = currentItem.getValue(); final ExcludeTreeController excludeControllerInstance = this; File currentDirectory = new File(currentItemValue.getAbsolutePath()); if (!currentDirectory.canRead()) { return; } currentItemValue.setLoaded(lazyChilds); currentItem.getChildren().clear(); for (File subFile : currentDirectory.listFiles(directoryFilter)) { TreeItem<DirectoryLazyCheckableTreeItem> children = new CheckBoxTreeItem<>( this.factoryDirectoryCheckableTreeItem.createItem(subFile.getAbsolutePath())); this.buildTreeLazily(children, nbPass - 1); currentItem.getChildren().add(children); } if (nbPass == 2) { currentItem.expandedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { excludeControllerInstance.buildTreeLazily(currentItem, 3); currentItem.expandedProperty().removeListener(this); } }); } }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); scene.setFill(Color.ALICEBLUE); stage.setScene(scene);/*from www .j a v a 2s . c o m*/ stage.show(); stage.setTitle("ChoiceBox Sample"); stage.setWidth(300); stage.setHeight(200); label.setStyle("-fx-font: 25 arial;"); label.setLayoutX(40); rect.setArcHeight(8); rect.setArcWidth(8); rect.setStroke(Color.BLUE); rect.setStrokeWidth(3); rect.setFill(Color.WHITE); final String[] greetings = new String[] { "Hello", "Hola", "??????", "?", "?????" }; final ChoiceBox cb = new ChoiceBox( FXCollections.observableArrayList("English", "Espaol", "???????", "????", "???")); cb.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue ov, Number value, Number new_value) { label.setText(greetings[new_value.intValue()]); } }); cb.setTooltip(new Tooltip("Select the language")); cb.setValue("English"); HBox hb = new HBox(); hb.getChildren().addAll(cb, label); hb.setSpacing(30); hb.setAlignment(Pos.CENTER); hb.setPadding(new Insets(10, 0, 0, 10)); ((Group) scene.getRoot()).getChildren().add(hb); }
From source file:Main.java
@Override public void start(Stage stage) { VBox box = new VBox(); Scene scene = new Scene(box, 200, 200); stage.setScene(scene);// ww w . ja va 2 s . c om stage.setTitle("ListViewSample"); box.getChildren().addAll(list, label); VBox.setVgrow(list, Priority.ALWAYS); label.setLayoutX(10); label.setLayoutY(115); label.setFont(Font.font("Verdana", 20)); list.setItems(data); list.setCellFactory(new Callback<ListView<String>, ListCell<String>>() { @Override public ListCell<String> call(ListView<String> list) { return new ColorRectCell(); } }); list.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() { public void changed(ObservableValue<? extends String> ov, String old_val, String new_val) { label.setText(new_val); label.setTextFill(Color.web(new_val)); } }); stage.show(); }
From source file:de.hs.mannheim.modUro.controller.diagram.ModeltypeDiagramController.java
public void init(ModelType modeltype) { this.modeltypeDiagram = new ModeltypeDiagram(modeltype); if (leftLastSelectedIndex == null || rightLastSelectedIndex == null) { initializeChoiceboxContent();/*from ww w . j a v a 2s . c om*/ } else { if (simulationContainsMetricType()) { setChoiceBoxContent(); setLeftChartContent(modeltypeDiagram.getMetricTypeNames().get(leftLastSelectedIndex)); setRightChartContent(modeltypeDiagram.getMetricTypeNames().get(rightLastSelectedIndex)); } else { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Warning"); alert.setHeaderText("Metrictype Warning"); alert.setContentText("Simulation does not have Metrictype: " + leftLastSelectedMetrictypename); alert.showAndWait(); initializeChoiceboxContent(); } } /*ChangeListerners for selected items in choicebox.*/ leftMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { setLeftChartContent(modeltypeDiagram.getMetricTypeNames().get(newValue.intValue())); leftLastSelectedIndex = newValue.intValue(); leftLastSelectedMetrictypename = modeltypeDiagram.getMetricTypeNames().get(leftLastSelectedIndex); } }); rightMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { setRightChartContent(modeltypeDiagram.getMetricTypeNames().get(newValue.intValue())); rightLastSelectedIndex = newValue.intValue(); rightLastSelectedMetrictypename = modeltypeDiagram.getMetricTypeNames().get(rightLastSelectedIndex); } }); }
From source file:org.nmrfx.processor.gui.PropertyManager.java
PropertyManager(ProcessorController processorController, final ListView scriptView, PropertySheet propertySheet, ObservableList<String> listItems, TextField opTextField, PopOver popOver) { this.processorController = processorController; this.scriptView = scriptView; this.listItems = listItems; this.opTextField = opTextField; this.propertySheet = propertySheet; this.popOver = popOver; doubleListener = new ChangeListener<Number>() { @Override/*w w w . j av a 2 s. com*/ public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { updateOp((PropertySheet.Item) observableValue); } }; intListener = new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { updateOp((PropertySheet.Item) observableValue); } }; boolListener = new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observableValue, Boolean bool, Boolean bool2) { updateOp((PropertySheet.Item) observableValue); } }; stringListener = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observableValue, String string, String string2) { updateOp((PropertySheet.Item) observableValue); } }; complexListener = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observableValue, String c1, String c2) { updateOp((PropertySheet.Item) observableValue); } }; listListener = new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observableValue, String c1, String c2) { updateOp((PropertySheet.Item) observableValue); } }; ChangeListener<Number> scriptOpListener = new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { int scriptIndex = (Integer) number2; try { if ((listItems.size() == 1) && (scriptIndex == -1)) { //there is a single item in the Cells -- Don't unselect scriptIndex = 0; } else if (scriptIndex != -1) { String selOp = (String) scriptView.getItems().get(scriptIndex); setPropSheet(scriptIndex, selOp); } else { setPropSheet(scriptIndex, ""); } } catch (Exception e) { System.out.println(e.getMessage()); } finally { currentIndex = scriptIndex; } } }; scriptView.getSelectionModel().selectedIndexProperty().addListener(scriptOpListener); propertySheet.setPropertyEditorFactory(new NvFxPropertyEditorFactory(processorController)); propertySheet.setMode(PropertySheet.Mode.NAME); propertySheet.setModeSwitcherVisible(false); propertySheet.setSearchBoxVisible(false); }
From source file:caillou.company.clonemanager.gui.customComponent.location.LocationController.java
@Override public void initialize(URL url, ResourceBundle rb) { this.disabledProperty().bind(getModel().disabledProperty()); final LocationController thisInstance = this; this.updatedProperty().addListener(new ChangeListener<Boolean>() { @Override//from w w w.j av a 2s.c o m public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { getModel().updateLocation(thisInstance.getPath(), thisInstance.getGroup().getValue()); } }); this.getModel().getEventBus().register(this); LocationsModel locationsModel = mainModel.getLocationsModel(); groupId.visibleProperty().bind(locationsModel.enableGroupingProperty()); groupId.managedProperty().bind(locationsModel.enableGroupingProperty()); groupId.getItems().add(Group.GROUPA); groupId.getItems().add(Group.GROUPB); path.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { boolean disableExclusion = true; if (newValue != null && !newValue.equals("")) { File file = new File(newValue); if (file.exists() && file.isDirectory()) { disableExclusion = false; } } filterButtonId.setDisable(disableExclusion); updated.set(!updated.get()); } }); groupId.valueProperty().addListener(new ChangeListener<Group>() { @Override public void changed(ObservableValue<? extends Group> observable, Group oldValue, Group newValue) { updated.set(!updated.get()); } }); disabledProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { path.setDisable(newValue); groupId.setDisable(newValue); button.setDisable(newValue); } }); filterButtonId.setDisable(true); /** * Due to the bug * "https://bitbucket.org/controlsfx/controlsfx/issue/185/nullpointerexception-when-using-popover" */ MainApp.getInstance().getStage().setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { errorPopOver.hide(Duration.millis(0)); } }); /** * End * */ }
From source file:ch.unibas.fittingwizard.presentation.MoleculeListPage.java
private void setupMoleculesTable() { moleculesTable.getItems().addListener(new ListChangeListener<Molecule>() { @Override//from w w w . j a v a 2s . c o m public void onChanged(Change<? extends Molecule> change) { boolean hasMolecules = change.getList().size() > 0; fittingParameterButton.setDisable(!hasMolecules); } }); moleculesTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Molecule>() { @Override public void changed(ObservableValue observableValue, Molecule o, Molecule o2) { selectedMolecule = o2; displayButton.setDisable(selectedMolecule == null); editButton.setDisable(selectedMolecule == null); removeButton.setDisable(selectedMolecule == null); } }); nameColumn.setCellValueFactory(new PropertyValueFactory<Molecule, String>("description")); }
From source file:benedict.zhang.addon.soundmanager.controller.SoundManagerConfigureController.java
private void initListeners() { this.isUpdatingOrSaving.addListener(new ChangeListener<Boolean>() { @Override// w w w . j a v a 2s . c o m public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { btnEditAndUpdate.setDisable(true); } else { btnEditAndUpdate.setDisable(false); } } }); }
From source file:sendsms.FXMLDocumentController.java
private ChangeListener onValueComboBoxChange() { return new ChangeListener<String>() { @Override/*from w w w . j a va 2s . c o m*/ public void changed(ObservableValue ov, String t, String newValue) { if (textOrden.getText().equals("")) { Alert alert = new Alert(AlertType.WARNING); alert.setHeaderText("Por favor complete el campo orden"); alert.showAndWait(); } else if (newValue.equals("Corregir direccin")) { setMessage(textOrden.getText() + DIRECCION_CONTENT); } else if (newValue.equals("Error con tarjeta")) { setMessage(textOrden.getText() + TARJETA_CONTENT); } else if (newValue.equals("Esperamos boleta")) { setMessage(textOrden.getText() + ESPERA_CONTENT); } else if (newValue.equals("Pasar")) { setMessage(textOrden.getText() + PASAR_CONTENT); } else if (newValue.equals("Conflicto en entrega")) { setMessage(textOrden.getText() + LLAMA_CONTENT); } else if (newValue.equals("Montos mayores")) { setMessage(textOrden.getText() + MONTOS_CONTENT); } } }; }
From source file:nl.han.ica.app.models.CodeEditor.java
/** * Initialize the webview that contains the browser environment for the CodeEditor. *///from ww w.ja v a 2s . c o m protected void initializeWebView() { logger.info("Initialising web view"); webView.getEngine().load(getClass().getResource("/editor/editor.html").toExternalForm()); webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() { @Override public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) { if (newState == Worker.State.SUCCEEDED && !scriptCache.isEmpty()) { for (String script : scriptCache) { execute(script); } scriptCache.clear(); } } }); }