Example usage for javafx.beans.value ChangeListener ChangeListener

List of usage examples for javafx.beans.value ChangeListener ChangeListener

Introduction

In this page you can find the example usage for javafx.beans.value ChangeListener ChangeListener.

Prototype

ChangeListener

Source Link

Usage

From source file:calendarioSeries.vistas.MainViewController.java

@FXML
public void initialize() {
    next = new Button();
    next.setId("next");
    previous = new Button();
    previous.setId("previous");
    imagenes.widthProperty().addListener(new ChangeListener<Number>() {
        @Override//from  w  ww. jav  a 2s . c  o  m
        public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth,
                Number newSceneWidth) {
            imagenes.hgapProperty().set(newSceneWidth.doubleValue() / 88);
        }
    });
    populateImagenes();
    showDetallesMes(mesActual);
}

From source file:com.wineshop.client.Home.java

@Override
public void initialize(URL url, ResourceBundle bundle) {
    // Setup of the table view
    vineyards.setSortAdapter(new TableViewSortAdapter<Vineyard>(tableVineyards, Vineyard.class));
    vineyards.getFilter().nameProperty().bindBidirectional(fieldSearch.textProperty());

    // Setup of the creation/edit form
    labelFormVineyard.textProperty()/*  w  w w  .jav  a  2  s.  co  m*/
            .bind(Bindings.when(vineyard.savedProperty()).then("Edit vineyard").otherwise("Create vineyard"));

    vineyard.instanceProperty().addListener(new ChangeListener<Vineyard>() {
        @Override
        public void changed(ObservableValue<? extends Vineyard> observable, Vineyard oldValue,
                Vineyard newValue) {
            if (oldValue != null) {
                fieldName.textProperty().unbindBidirectional(oldValue.nameProperty());
                fieldAddress.textProperty().unbindBidirectional(oldValue.getAddress().addressProperty());
                listWines.setItems(null);
            }
            if (newValue != null) {
                fieldName.textProperty().bindBidirectional(newValue.nameProperty());
                fieldAddress.textProperty().bindBidirectional(newValue.getAddress().addressProperty());
                listWines.setItems(newValue.getWines());
            }
        }
    });

    // Define the cell factory for the list of wines 
    listWines.setCellFactory(new Callback<ListView<Wine>, ListCell<Wine>>() {
        public ListCell<Wine> call(ListView<Wine> listView) {
            return new WineListCell();
        }
    });

    buttonDelete.visibleProperty().bind(vineyard.savedProperty());
    buttonDelete.disableProperty().bind(Bindings.not(identity.ifAllGranted("ROLE_ADMIN")));
    buttonSave.disableProperty().bind(Bindings.not(vineyard.dirtyProperty()));
    buttonCancel.disableProperty()
            .bind(Bindings.not(Bindings.or(vineyard.savedProperty(), vineyard.dirtyProperty())));

    // Link the table selection and the entity instance in the form 
    select(null);
    tableVineyards.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Vineyard>() {
        @Override
        public void changed(ObservableValue<? extends Vineyard> property, Vineyard oldSelection,
                Vineyard newSelection) {
            select(newSelection);
        }
    });

    formVineyard.addEventHandler(ValidationResultEvent.INVALID, new EventHandler<ValidationResultEvent>() {
        @Override
        public void handle(ValidationResultEvent event) {
            ((Node) event.getTarget()).setStyle("-fx-border-color: red");
            if (event.getTarget() instanceof TextInputControl && event.getErrorResults() != null
                    && event.getErrorResults().size() > 0) {
                Tooltip tooltip = new Tooltip(event.getErrorResults().get(0).getMessage());
                tooltip.setAutoHide(true);
                ((TextInputControl) event.getTarget()).setTooltip(tooltip);
            }
        }
    });
    formVineyard.addEventHandler(ValidationResultEvent.VALID, new EventHandler<ValidationResultEvent>() {
        @Override
        public void handle(ValidationResultEvent event) {
            ((Node) event.getTarget()).setStyle("-fx-border-color: null");
            if (event.getTarget() instanceof TextInputControl) {
                Tooltip tooltip = ((TextInputControl) event.getTarget()).getTooltip();
                if (tooltip != null && tooltip.isActivated())
                    tooltip.hide();
                ((TextInputControl) event.getTarget()).setTooltip(null);
            }
        }
    });
}

From source file:ruleprunermt2.FXMLDocumentController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    kValue.setText("k= " + String.valueOf((int) kSlider.getValue()));
    kSlider.valueProperty().addListener(new ChangeListener() {
        @Override//from w ww.  j  av  a2s. c o  m
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            kValue.setText("k= " + String.valueOf((int) kSlider.getValue()));
        }

    });

    columnStage.setCellValueFactory(new PropertyValueFactory<>("ruleStage"));
    columnProperty.setCellValueFactory(new PropertyValueFactory<>("property"));
    columnMin.setCellValueFactory(new PropertyValueFactory<>("min"));
    columnAvg.setCellValueFactory(new PropertyValueFactory<>("avg"));
    columnMax.setCellValueFactory(new PropertyValueFactory<>("max"));

    //tableData.add(new Statistics("Raw rules", "Length", 1.0, 2.0, 3.0));
    statisticsTable.setItems(tableData);

    toggle1.setSelected(false);
    toggle2.setSelected(true);
    toggle3.setSelected(true);
    toggle4.setSelected(false);

}

From source file:pe.edu.system.jcmr.controlador.LoguinController.java

public void clearMessage() {
    cboIdioma.valueProperty().addListener(new ChangeListener<BaseEntity>() {

        @Override/*from   w  w  w.  j  a v a2  s . co m*/
        public void changed(ObservableValue<? extends BaseEntity> observable, BaseEntity oldValue,
                BaseEntity newValue) {
            if (!newValue.getCodigo().equals("0")) {
                lblMensaje.setText("");
            }

        }
    });
    txtUsuario.textProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue.length() >= 0) {
            lblMensaje.setText("");
        }
    });
    txtPassword.textProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue.length() >= 0) {
            lblMensaje.setText("");
        }
    });

}

From source file:caillou.company.clonemanager.gui.customComponent.critere.CritereController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    mainModel.getCritereModel().getFormat().allProperty().bind(formatAllId.selectedProperty());
    mainModel.getCritereModel().getFormat().videoProperty().bind(
            Bindings.and(formatVideoId.selectedProperty(), Bindings.not(formatVideoId.disableProperty())));
    mainModel.getCritereModel().getFormat().audioProperty().bind(
            Bindings.and(formatAudioId.selectedProperty(), Bindings.not(formatAudioId.disableProperty())));
    mainModel.getCritereModel().getFormat().imageProperty().bind(
            Bindings.and(formatImageId.selectedProperty(), Bindings.not(formatImageId.disableProperty())));
    mainModel.getCritereModel().getFormat().archiveProperty().bind(
            Bindings.and(formatArchiveId.selectedProperty(), Bindings.not(formatArchiveId.disableProperty())));

    LongBinding minimumSizeComputationBinding = new LongBinding() {
        {/*from   www  .  j  a v a2 s .co m*/
            super.bind(minimumSizeFormatId.valueProperty(), sizeMinId.valueProperty());
        }

        @Override
        protected long computeValue() {
            if (minimumSizeFormatId.getValue().equals("octet")) {
                return (long) sizeMinId.valueProperty().get() * 1;
            }
            if (minimumSizeFormatId.getValue().equals("kilo octet")) {
                return (long) sizeMinId.valueProperty().get() * 1000;
            }
            if (minimumSizeFormatId.getValue().equals("mega octet")) {
                return (long) sizeMinId.valueProperty().get() * 1000000;
            }
            if (minimumSizeFormatId.getValue().equals("giga octet")) {
                return (long) sizeMinId.valueProperty().get() * 1000000000;
            }
            throw new IllegalArgumentException("Unkowned size format");
        }
    };

    mainModel.getCritereModel().getSize().minimalSizeProperty().bind(minimumSizeComputationBinding);

    LongBinding maximumSizeComputationBinding = new LongBinding() {
        {
            super.bind(maximumSizeFormatId.valueProperty(), sizeMaxId.valueProperty());
        }

        @Override
        protected long computeValue() {
            if (maximumSizeFormatId.getValue().equals("octet")) {
                return (long) sizeMaxId.valueProperty().get() * 1;
            }
            if (maximumSizeFormatId.getValue().equals("kilo octet")) {
                return (long) sizeMaxId.valueProperty().get() * 1000;
            }
            if (maximumSizeFormatId.getValue().equals("mega octet")) {
                return (long) sizeMaxId.valueProperty().get() * 1000000;
            }
            if (maximumSizeFormatId.getValue().equals("giga octet")) {
                return (long) sizeMaxId.valueProperty().get() * 1000000000;
            }
            throw new IllegalArgumentException("Unkowned size format");
        }
    };

    mainModel.getCritereModel().getSize().minimalSizeProperty().bind(minimumSizeComputationBinding);
    mainModel.getCritereModel().getSize().maximalSizeProperty().bind(maximumSizeComputationBinding);

    formatAllId.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            disableEnableCheckboxes(newValue);
            if (newValue) {
                formatVideoId.setSelected(false);
                formatAudioId.setSelected(false);
                formatImageId.setSelected(false);
                formatArchiveId.setSelected(false);
            }
        }
    });
}

From source file:com.rvantwisk.cnctools.operations.customgcode.CustomGCodeController.java

@FXML
void initialize() {
    errors.setTooltip(new Tooltip());
    modelToForm();/*  w ww .  j av  a2s  .  c  om*/
    gCodeText.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observableValue, String s, String s2) {
            reRenderModel();
        }
    });
    reRenderModel();
}

From source file:com.SignalDiagram.FXMLDocumentController.java

private void initListeners() {

    txtField_binaryInput.textProperty()/*ww  w.  j a v a  2  s  .  com*/
            .addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
                if (!newValue.matches("[0-1]*")) {
                    txtField_binaryInput.setText(oldValue);
                } else if (!newValue.isEmpty()) {

                    m_digitalSignal.setMessage(newValue);
                    m_analogSignal.setMessage(newValue);

                    updateDigitalChart(m_digitalSerie, m_digitalChartData, m_digitalSignal);
                    updateAnalogChart(m_analogSerieList, m_analogChartData, m_analogSignal);
                }

            });

    txtField_seed.textProperty()
            .addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
                if (!newValue.matches("[0-9]*")) {
                    txtField_seed.setText(oldValue);
                } else if (!newValue.isEmpty()) {

                    txtField_seed.setText("" + m_analogSignal.setSeed(Integer.parseInt(newValue)).getSeed());

                    updateAnalogChart(m_analogSerieList, m_analogChartData, m_analogSignal);
                }

            });

    txtField_bits.textProperty()
            .addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
                if (!newValue.matches("[1-9][0-9]*")) {
                    txtField_bits.setText("1");
                } else if (!newValue.isEmpty()) {

                    txtField_bits
                            .setText("" + m_analogSignal.setNbBits(Integer.parseInt(newValue)).getNbBits());

                    updateAnalogChart(m_analogSerieList, m_analogChartData, m_analogSignal);
                }

            });

    cmbBox_DigitalType.valueProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue ov, String oldType, String newType) {
            m_digitalChart.setTitle("Digital Signal: " + WordUtils.capitalize(newType));
            m_digitalSignal.setType(newType);

            updateDigitalChart(m_digitalSerie, m_digitalChartData, m_digitalSignal);
        }
    });

    m_scrollPane.widthProperty().addListener(evt -> {
        m_digitalChart.setPrefWidth(m_scrollPane.getWidth());
        m_analogChart.setPrefWidth(m_scrollPane.getWidth());
    });

    m_scrollPane.heightProperty().addListener(evt -> {
        m_digitalChart.setPrefHeight(m_scrollPane.getHeight() / 3);
        m_analogChart.setPrefHeight(m_scrollPane.getHeight() / 3);
    });

    radioAnalogGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override
        public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
            if (radioAnalogGroup.getSelectedToggle() == radBtn_amplitude) {
                m_analogSignal.setType(AnalogSignal.analogType.AMPLITUDE);
                updateAnalogChart(m_analogSerieList, m_analogChartData, m_analogSignal);
            }
            if (radioAnalogGroup.getSelectedToggle() == radBtn_frequence) {
                m_analogSignal.setType(AnalogSignal.analogType.FREQUENCE);
                updateAnalogChart(m_analogSerieList, m_analogChartData, m_analogSignal);
            }
            if (radioAnalogGroup.getSelectedToggle() == radBtn_phase) {
                m_analogSignal.setType(AnalogSignal.analogType.PHASE);
                updateAnalogChart(m_analogSerieList, m_analogChartData, m_analogSignal);
            }
        }
    });

}

From source file:sopho.Ofeloumenoi.AddOfeloumenoiController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    tekna.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {

        @Override/*ww w.  j a  v  a2 s. co  m*/
        public void handle(MouseEvent event) {
            if (prefs.getPrefs("tableTipOfeloumenoi").equals("true")) {
                sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                        "?",
                        "  ?       '?  '  ?  . ? ?    enter   ?  .         .",
                        "notify");
                cm.showAndWait();
                prefs.setPrefs("tableTipOfeloumenoi", "false");
            }
        }
    });

    anenergos.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (newValue) {
                barcode.setStyle("-fx-background-color: #cc334a; -fx-text-fill:white;");
                if (showAnenergosTip.equals("true")) {
                    sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                            "?...",
                            "  ?   ?,    barcode      ?    ?   ? ?  ?? ?.        !",
                            "confirm");
                    cm.showAndWait();
                    prefs.setPrefs("showAnenergosTip", "false");
                }
            } else {
                barcode.setStyle("");
            }
        }
    });

    anergos.selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            epaggelma.setDisable(!newValue);//if the anergos checkbox is selected the epaggelma textFiels is disabled and vise versa
        }
    });

    //we use a listener to know if the user adds a photo using the TakePhoto class
    PhotoListener.strProperty().addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            if (PhotoListener.getStr() != null) {
                changePhotoButton.setText(" ?");
            }
            PhotoID = (String) newVal;

            BufferedImage bf = bfImage(PhotoID);

            if (bf != null) {
                Image im = SwingFXUtils.toFXImage(bf, null);
                image.setImage(im);
            }

        }
    });

    //initialzing tekna table
    data = getInitialTableData();

    tekna.setItems(data);
    tekna.setEditable(true);
    etosCol.setCellValueFactory(new PropertyValueFactory<tableManager, String>("etos"));

    //lets make the table cells editable
    etosCol.setCellFactory(TextFieldTableCell.forTableColumn());
    etosCol.setOnEditCommit(new EventHandler<CellEditEvent<tableManager, String>>() {

        @Override
        public void handle(CellEditEvent<tableManager, String> t) {
            if (!NumberUtils.isNumber(t.getNewValue())) {
                sopho.Messages.CustomMessageController cm = new sopho.Messages.CustomMessageController(null,
                        "?!",
                        "      ?  ?  ??. ?    ?  .",
                        "error");
                cm.showAndWait();
                ((tableManager) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                        .setEtos("?  ");
            } else {
                ((tableManager) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                        .setEtos(t.getNewValue());
            }
        }
    });

    tekna.getColumns().setAll(etosCol);
    //end of initialization of tekna table

    //initialize oikKatastasi combobox
    oikKatastasi.getItems().addAll("", "", "", "?");

    //initialize asfForeas comboBox
    asfForeas.getItems().addAll("", "", "", "", "",
            "", "", "", "  ", "");
}

From source file:com.properned.application.SystemController.java

public void initialize() {
    logger.info("Initialize System controller");
    localeButton.disableProperty().bind(multiLanguageProperties.isLoadedProperty().not());
    saveButton.disableProperty().bind(multiLanguageProperties.isDirtyProperty().not()
            .or(multiLanguageProperties.isLoadedProperty().not()));
    Stage primaryStage = Properned.getInstance().getPrimaryStage();
    primaryStage.titleProperty()/*ww w .j ava 2s.  c o m*/
            .bind(multiLanguageProperties.baseNameProperty()
                    .concat(Bindings.when(multiLanguageProperties.isLoadedProperty())
                            .then(new SimpleStringProperty(" (")
                                    .concat(multiLanguageProperties.parentDirectoryPathProperty()).concat(")"))
                            .otherwise(""))
                    .concat(Bindings.when(multiLanguageProperties.isDirtyProperty()).then(" *").otherwise("")));

    FilteredList<String> filteredList = new FilteredList<>(multiLanguageProperties.getListMessageKey(),
            new Predicate<String>() {
                @Override
                public boolean test(String t) {
                    String filter = filterText.getText();
                    if (filter == null || filter.equals("")) {
                        return true;
                    }
                    return t.contains(filter);
                }
            });
    SortedList<String> sortedList = new SortedList<>(filteredList, new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            return o1.compareTo(o2);
        }
    });
    messageKeyList.setItems(sortedList);
    filterText.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            // Filter the list
            filteredList.setPredicate(new Predicate<String>() {
                @Override
                public boolean test(String t) {
                    String filter = filterText.getText();
                    if (filter == null || filter.equals("")) {
                        return true;
                    }
                    return t.contains(filter);
                }
            });

            // check the add button disabled status
            if (isKeyCanBeAdded(newValue)) {
                addButton.setDisable(false);
            } else {
                addButton.setDisable(true);
            }

        }

    });
    ChangeListener<String> changeMessageListener = new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            logger.info("Message key selection changed : " + newValue);
            valueList.setItems(FXCollections.observableArrayList());

            valueList.setItems(FXCollections
                    .observableArrayList(multiLanguageProperties.getMapPropertiesByLocale().keySet()));
        }
    };
    messageKeyList.getSelectionModel().selectedItemProperty().addListener(changeMessageListener);
    messageKeyList.setCellFactory(c -> new MessageKeyListCell(multiLanguageProperties));

    valueList.setCellFactory(c -> new ValueListCell(multiLanguageProperties, messageKeyList));

    filterText.setOnKeyReleased(new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.DOWN) {
                messageKeyList.requestFocus();
                event.consume();
            } else if (event.getCode() == KeyCode.ENTER) {
                addKey();
                event.consume();
            }
        }
    });
}

From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java

public ClassTree(JEVisDataSource ds) {
    super();/*ww w .  jav  a 2  s.  c o  m*/
    try {
        _ds = ds;

        _itemCache = new HashMap<>();
        _graphicCache = new HashMap<>();
        _itemChildren = new HashMap<>();

        JEVisClass root = new JEVisRootClass(ds);
        TreeItem<JEVisClass> rootItem = buildItem(root);

        setShowRoot(true);
        rootItem.setExpanded(true);

        getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        _editor.setTreeView(this);

        setCellFactory(new Callback<TreeView<JEVisClass>, TreeCell<JEVisClass>>() {

            //                @Override
            //                public TreeCell<JEVisClass> call(TreeView<JEVisClass> p) {
            //                    return new ClassCell();
            //                }
            @Override
            public TreeCell<JEVisClass> call(TreeView<JEVisClass> param) {
                return new TreeCell<JEVisClass>() {
                    //                        private ImageView imageView = new ImageView();

                    @Override
                    protected void updateItem(JEVisClass item, boolean empty) {
                        super.updateItem(item, empty);

                        if (!empty) {
                            ClassGraphic gc = getClassGraphic(item);

                            setContextMenu(gc.getContexMenu());
                            //                                setText(item);
                            setGraphic(gc.getGraphic());
                        } else {
                            setText(null);
                            setGraphic(null);
                        }
                    }
                };
            }
        });

        getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<JEVisClass>>() {

            @Override
            public void changed(ObservableValue<? extends TreeItem<JEVisClass>> ov, TreeItem<JEVisClass> t,
                    TreeItem<JEVisClass> t1) {
                try {
                    if (t1 != null) {
                        _editor.setJEVisClass(t1.getValue());
                    }
                } catch (Exception ex) {
                    System.out.println("Error while changing editor: " + ex);
                }

            }
        });

        addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {

            @Override
            public void handle(KeyEvent t) {
                if (t.getCode() == KeyCode.F2) {
                    System.out.println("F2 rename event");
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            fireEventRename();
                        }
                    });

                } else if (t.getCode() == KeyCode.DELETE) {

                    fireDelete(getSelectionModel().getSelectedItem().getValue());
                }
            }

        });

        setId("objecttree");

        getStylesheets().add("/styles/Styles.css");
        setPrefWidth(500);

        setRoot(rootItem);
        setEditable(true);

    } catch (Exception ex) {
        //            Logger.getLogger(ObjectTree.class.getName()).log(Level.SEVERE, null, ex);
        ex.printStackTrace();
    }

}