Java 类javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory 实例源码

项目:redisfx    文件:IntegerSpinner.java   
private void checkEditorText() {
    IntegerSpinnerValueFactory valueFactory = getVF();

    try {
        int value = Integer.parseInt(getEditor().getText());
        int min = valueFactory.getMin();
        int max = valueFactory.getMax();

        value = Math.min(Math.max(min, value), max);

        getEditor().setText(String.valueOf(value));
        valueFactory.setValue(value);

    } catch (NumberFormatException e) {
        getEditor().setText(String.valueOf(valueFactory.getValue()));
    }
}
项目:waterrower-workout    文件:CreateUserDialog.java   
private void initFieldsAndValidation(ResourceBundle bundle) {

        // Setup input for name.
        validationSupport.registerValidator(txtName, false,
                new TextValidator(bundle.getString("dialog_create_user_error_name_required"), 255, false));

        // Setup input for birthday.
        validationSupport.registerValidator(dateBirthday.getEditor(), false,
                new DateValidator(bundle.getString("dialog_create_user_error_birthday_invalid"), true));

        // Setup input for height.
        spnHeight.setValueFactory(new IntegerSpinnerValueFactory(0, 9999, 0));
        spnHeight.focusedProperty().addListener(new SpinnerFocusChangeListener<>(spnHeight));
        validationSupport.registerValidator(spnHeight.getEditor(), false,
                new IntegerValidator(bundle.getString("dialog_create_user_error_height_invalid"), 0, 9999, true));
        lblHeightUnit.setText(bundle.getString(heightUnitConverter.getUnit().getI18N()));

        // Register validation.
        validationSupport.invalidProperty().addListener((observable, oldValue, newValue) -> {
            getDialogPane().lookupButton(OK).setDisable(newValue);
        });
        validationSupport.redecorate();
    }
项目:redisfx    文件:ListTabController.java   
public void initialize() {
    super.initialize();

    //////////////////////////////////////////////////////////////

    spnFromIndex.setValueFactory(new IntegerSpinnerValueFactory(0, Integer.MAX_VALUE, 0));
    spnToIndex.setValueFactory(new IntegerSpinnerValueFactory(Integer.MIN_VALUE, Integer.MAX_VALUE, 100));

    Fx.fixIntegerSpinners(spnFromIndex, spnToIndex);

    //////////////////////////////////////////////////////////////

    txtKey.setOnKeyPressed(event -> {
        if (event.getCode() == KeyCode.ENTER) {
            listValues();
        }
    });

    //////////////////////////////////////////////////////////////

    // List key events
    lstValues.setOnKeyPressed(event -> {
        if (event.getCode() == KeyCode.C && event.isControlDown()) {    // Ctrl+C
            listItemCopyClicked();
        } else if (event.getCode() == KeyCode.DELETE) {                 // Delete
            deleteItem();
        }
    });

    // List mouse events
    lstValues.setOnMouseClicked(event -> {
        String value = lstValues.getSelectionModel().getSelectedItem();
        if (event.getClickCount() == 2 && value != null) {
            editListItem();
        }
    });
}
项目:git-rekt    文件:PackageListItemController.java   
/**
 * Called by JavaFX.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    int min = 0;
    int max = 100;
    int initialValue = 0;
    qtySpinner.setValueFactory(new IntegerSpinnerValueFactory(min, max, initialValue));
    qtySpinner.valueProperty().addListener(
        (obs, oldValue, newValue) -> {
            listController.updatePackageQty(this.packageData, newValue);
        }
    );
}
项目:Retrospector    文件:FactoidChartPopupController.java   
@Override
public void initialize(URL url, ResourceBundle rb) {
    minCount.setEditable(true);
    minCount.setValueFactory(new IntegerSpinnerValueFactory(min, max,min));
    minCount.valueProperty().addListener((observe, old, neo) -> update.run());
    maxCount.setEditable(true);
    maxCount.setValueFactory(new IntegerSpinnerValueFactory(min, max,max));
    maxCount.valueProperty().addListener((observe, old, neo) -> update.run());
}
项目:JttDesktop    文件:DimensionsPanelTest.java   
@Test public void columnsSpinnerShouldBeBound(){
   IntegerSpinnerValueFactory factory = ( IntegerSpinnerValueFactory )systemUnderTest.columnsSpinner().getValueFactory();
   Assert.assertEquals( 
            DimensionsPanel.MINIMUM_COLUMNS, 
            factory.getMin() 
   );
   Assert.assertEquals( 
            DimensionsPanel.MAXIMUM_COLUMNS, 
            factory.getMax() 
   );
}
项目:JttDesktop    文件:IntegerPropertySpinnerTest.java   
@Before public void initialiseSystemUnderTest(){
   TestApplication.startPlatform();
   PlatformImpl.runAndWait( () -> {
      systemUnderTest = new IntegerPropertySpinner();
      systemUnderTest.setValueFactory( new IntegerSpinnerValueFactory( 0, 100 ) );
   } );
}
项目:3DScanner.RaspberryPi    文件:UIController.java   
private void setUpSpinnerInt(Spinner<Integer> spinner, int pos, int min, int max, int increment, int savedSet ){
    IntegerSpinnerValueFactory oswFactory = new SpinnerValueFactory.IntegerSpinnerValueFactory(min, max, savedSet, increment);
    spinner.setValueFactory(oswFactory);
    spinner.valueProperty().addListener((obs, oldValue, newValue) -> {
    System.out.println("New value: "+newValue);
    // hier könnte es rundungsfehler von double auf Number geben
    setValueSettings(pos, newValue);
    });
}
项目:JVx.javafx    文件:FXDateTimePickerSkin.java   
/**
 * Creates the {@link ComboBox} used for selection a year.
 * 
 * @return the {@link ComboBox} for selecting a year.
 */
private Spinner<Integer> createYearSelector()
{
    Spinner<Integer> yearSpinner = new FXSpinnerRT40623<>(new IntegerSpinnerValueFactory(Integer.MIN_VALUE, Integer.MAX_VALUE));
    yearSpinner.getStyleClass().add("year-selector");
    yearSpinner.setEditable(true);
    yearSpinner.valueProperty().addListener(this::onSelectedYearChanged);

    return yearSpinner;
}
项目:speedment    文件:DefaultSpinnerItem.java   
private static void setSpinnerBehaviour(
    final IntegerSpinnerValueFactory svf,
    final boolean useDefaultValue,
    final ObservableIntegerValue defaultValue,
    final ObjectProperty<Integer> customValue
) {
    if (useDefaultValue) {
        svf.valueProperty().unbindBidirectional(customValue);
        svf.setValue(defaultValue.get());
    } else {
        svf.setValue(customValue.getValue());
        svf.valueProperty().bindBidirectional(customValue);
    }
}
项目:CalendarFX    文件:TimeRangeFieldSkin.java   
public TimeRangeFieldSkin(TimeRangeField control) {
    super(control);

    ComboBox<TimeRangeField.TimeRangeFieldValue> valuesComboBox = new ComboBox<>();
    valuesComboBox.setConverter(new TimeRangeFieldValueStringConverter());
    valuesComboBox.setItems(control.getValues());
    valuesComboBox.valueProperty().bindBidirectional(control.valueProperty());
    valuesComboBox.setVisibleRowCount(5);

    datePicker = new DatePicker();
    datePicker.getEditor().setPrefColumnCount(6);
    datePicker.valueProperty().bindBidirectional(control.onDateProperty());
    datePicker.managedProperty().bind(datePicker.visibleProperty());
    datePicker.setEditable(false);

    weekValueFactory = new IntegerSpinnerValueFactory(1, 52);
    weekValueFactory.valueProperty().addListener(obs -> control.setOnWeekNumber(weekValueFactory.getValue()));
    control.onWeekNumberProperty().addListener(obs -> {
        if (control.getOnWeekNumber() != null) {
            weekValueFactory.setValue(control.getOnWeekNumber());
        }
    });
    weekNumberSpinner = new Spinner<>();
    weekNumberSpinner.setValueFactory(weekValueFactory);
    weekNumberSpinner.managedProperty().bind(weekNumberSpinner.visibleProperty());
    weekNumberSpinner.setPrefWidth(70);

    monthYearValueFactory = new IntegerSpinnerValueFactory(1972, 3000);
    monthYearValueFactory.valueProperty().addListener(obs -> control.setMonthYear(monthYearValueFactory.getValue()));
    control.monthYearProperty().addListener(obs -> {
        if (control.getMonthYear() != null) {
            monthYearValueFactory.setValue(control.getMonthYear());
        }
    });

    monthYearSpinner = new Spinner<>();
    monthYearSpinner.getEditor().setPrefColumnCount(6);
    monthYearSpinner.setValueFactory(monthYearValueFactory);
    monthYearSpinner.managedProperty().bind(monthYearSpinner.visibleProperty());

    afterUnitsValueFactory = new IntegerSpinnerValueFactory(1, 500);
    afterUnitsValueFactory.valueProperty().addListener(obs -> control.setAfterUnits(afterUnitsValueFactory.getValue()));
    control.afterUnitsProperty().addListener(obs -> {
        if (control.getAfterUnits() != null) {
            afterUnitsValueFactory.setValue(control.getAfterUnits());
        }
    });
    afterUnitsSpinner = new Spinner<>();
    afterUnitsSpinner.getEditor().setPrefColumnCount(4);
    afterUnitsSpinner.setValueFactory(afterUnitsValueFactory);
    afterUnitsSpinner.managedProperty().bind(afterUnitsSpinner.visibleProperty());
    afterUnitsLabel = new Label();
    afterUnitsLabel.managedProperty().bind(afterUnitsLabel.visibleProperty());

    InvalidationListener listener = obs -> layout();
    control.viewTypeProperty().addListener(listener);
    control.valueProperty().addListener(listener);

    HBox container = new HBox(5, valuesComboBox, datePicker, weekNumberSpinner, monthYearSpinner, afterUnitsSpinner, afterUnitsLabel);
    container.setAlignment(Pos.CENTER_LEFT);
    HBox.setHgrow(valuesComboBox, Priority.ALWAYS);
    HBox.setHgrow(datePicker, Priority.SOMETIMES);

    getChildren().add(container);
    layout();
}
项目:redisfx    文件:IntegerSpinner.java   
private IntegerSpinnerValueFactory getVF() {
    return (IntegerSpinnerValueFactory) getValueFactory();
}
项目:fx-log    文件:PreferencesController.java   
private void configureIntegerSpinner(Spinner<Integer> spinner, Property<Integer> prop, int min, int max) {
    IntegerSpinnerValueFactory factory = new IntegerSpinnerValueFactory(min, max);
    factory.valueProperty().bindBidirectional(prop);
    spinner.setValueFactory(factory);
}
项目:Simulizer    文件:IntegerControl.java   
public IntegerControl(Options o, IntegerSetting setting) {
    setSpacing(3);

    // Option Name
    Label title = new Label(setting.getHumanName());
    title.getStyleClass().add("title");
    title.setFont(new Font(20));
    getChildren().add(title);

    // Option Desc
    if (!setting.getDescription().equals("")) {
        Label desc = new Label(setting.getDescription());
        desc.getStyleClass().add("description");
        desc.setFont(new Font(14));
        desc.setWrapText(true);
        getChildren().add(desc);
    }

    // Option Value
    Spinner<Integer> value = new Spinner<>();
    IntegerSpinnerValueFactory factory = new IntegerSpinnerValueFactory(0, 0);
    factory.setMax(setting.getHighBound());
    factory.setMin(setting.getLowBound());
    factory.setValue(setting.getValue());
    value.setValueFactory(factory);
    value.setEditable(true);
    value.getStyleClass().add("value");
    value.setPrefWidth(Double.MAX_VALUE);
    value.valueProperty().addListener(e -> {
        if (setting.isValid(value.getValue())) {
            o.madeChanges();
            setting.setValue(value.getValue());
        } else
            value.getValueFactory().setValue(setting.getValue());
    });
    getChildren().add(value);

    // Tooltip
    // Tooltip tooltip = new Tooltip(setting.getDescription());
    // Tooltip.install(title, tooltip);
    // Tooltip.install(value, tooltip);
}