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


Java Spinner.setValueFactory方法代码示例

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


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

示例1: createListSpinner

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
private Spinner<Object> createListSpinner() {
    Spinner<Object> spinner = new Spinner<>();
    spinner.setId("list-spinner");
    List<Object> names = new ArrayList<Object>();
    names.add("January");
    names.add("February");
    names.add("March");
    names.add("April");
    names.add("May");
    names.add("June");
    names.add("July");
    names.add("August");
    names.add("September");
    names.add("October");
    names.add("November");
    names.add("December");
    spinner.setValueFactory(new SpinnerValueFactory.ListSpinnerValueFactory<Object>(FXCollections.observableArrayList(names)));
    return spinner;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:SpinnerSample.java

示例2: createDoubleSpinner

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
private Spinner<Double> createDoubleSpinner() {
    Spinner<Double> spinner = new Spinner<Double>();
    spinner.setId("double-spinner");
    spinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(25.50, 50.50));
    spinner.setEditable(true);
    return spinner;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:SpinnerSample.java

示例3: initializeSpinner

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
public  static void initializeSpinner(final Spinner<Integer> spinner, final int minValue, final int maxValue, final int initialValue) {
    spinner.getEditor().setOnKeyPressed(event -> {
        switch (event.getCode()) {
            case UP:
                spinner.increment(1);
                break;
            case DOWN:
                spinner.decrement(1);
                break;
        }
    });
    spinner.setOnScroll(e -> {
        spinner.increment((int) (e.getDeltaY() / e.getMultiplierY()));
    });

    SpinnerValueFactory<Integer> factory = new SpinnerValueFactory.IntegerSpinnerValueFactory(minValue, maxValue, initialValue);
    spinner.setValueFactory(factory);
    spinner.setEditable(true);

    TextFormatter<Integer> formatter = new TextFormatter<>(factory.getConverter(), factory.getValue());
    spinner.getEditor().setTextFormatter(formatter);
    factory.valueProperty().bindBidirectional(formatter.valueProperty());

}
 
开发者ID:gmuecke,项目名称:boutique-de-jus,代码行数:25,代码来源:SpinnerUtil.java

示例4: setSpinnerValueFactory

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
public void setSpinnerValueFactory(final Spinner _spinner, final String _newValue) {
    ObservableList<String> items = FXCollections.observableArrayList("Jonathan", "Julia", "Henry");
    switch (_newValue) {
        case "Integer": {
            _spinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(5, 10));
            break;
        }

        case "List<String>": {
            _spinner.setValueFactory(new SpinnerValueFactory.ListSpinnerValueFactory<>(items));
            break;
        }
        /*    postponed.  see https://javafx-jira.kenai.com/browse/RT-37968
        case "Calendar": {
            _spinner.setValueFactory(new SpinnerValueFactory.LocalDateSpinnerValueFactory());
            break;
        }
        */
        case "Double": {
            _spinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0.0, 1.0, 0.5, 0.05));
            break;
        }
        default: {
            _spinner.setValueFactory(null);
            break;
        }

    }

}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:31,代码来源:SpinnerApp.java

示例5: DoubleControl

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
public DoubleControl(Options o, DoubleSetting setting) {
	setSpacing(3);
	
	// Option Name
	Label title = new Label(setting.getHumanName());
	title.setFont(new Font(20));
	title.getStyleClass().add("title");
	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<Double> value = new Spinner<>();
	DoubleSpinnerValueFactory factory = new DoubleSpinnerValueFactory(0, 0);
	factory.setMax(setting.getHighBound());
	factory.setMin(setting.getLowBound());
	factory.setValue(setting.getValue());
	double step = (setting.getHighBound() - setting.getLowBound()) / 1000;
	factory.setAmountToStepBy(step <= 20 ? step : 20);
	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);
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:40,代码来源:DoubleControl.java

示例6: setUpSpinnerInt

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
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);
	});
}
 
开发者ID:Raldir,项目名称:3DScanner.RaspberryPi,代码行数:10,代码来源:UIController.java

示例7: setUpSpinnerDouble

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
private void setUpSpinnerDouble(Spinner<Double> spinner, int pos, double min, double max, double increment, double savedSet){
	DoubleSpinnerValueFactory oswFactory = new SpinnerValueFactory.DoubleSpinnerValueFactory(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);
	});
	
}
 
开发者ID:Raldir,项目名称:3DScanner.RaspberryPi,代码行数:11,代码来源:UIController.java

示例8: start

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
@Override
public void start(final Stage stage)
{
    final Label label = new Label("Demo:");

    SpinnerValueFactory<Double> svf = new SpinnerValueFactory.DoubleSpinnerValueFactory(0, 1000);
    Spinner<Double> spinner = new Spinner<>();
    spinner.setValueFactory(svf);
    spinner.editorProperty().getValue().setStyle("-fx-text-fill:" + "black");
    spinner.editorProperty().getValue().setBackground(
            new Background(new BackgroundFill(Color.AZURE, CornerRadii.EMPTY, Insets.EMPTY)));


    //spinner.getStyleClass().add(Spinner.STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL);
    //int x = spinner.getStyleClass().indexOf(Spinner.STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL);
    //if (x > 0) spinner.getStyleClass().remove(x);

    spinner.setEditable(true);
    spinner.setPrefWidth(80);

    spinner.valueProperty().addListener((prop, old, value) ->
    {
        System.out.println("Value: " + value);
    });

    final HBox root = new HBox(label, spinner);

    final Scene scene = new Scene(root, 800, 700);
    stage.setScene(scene);
    stage.setTitle("Spinner Demo");

    stage.show();
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:34,代码来源:SpinnerDemo.java

示例9: addSpinnerAndButton

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
private void addSpinnerAndButton() {
	List<String> propertyTypeList = new ArrayList<String>();
	propertyTypeList.add("String");
	propertyTypeList.add("Number");
	propertyTypeList.add("Date");
	propertyTypeList.add("Pointset");
	ObservableList<String> obsPropTypeList = FXCollections.observableList(propertyTypeList);
	SpinnerValueFactory<String> svf = new SpinnerValueFactory.ListSpinnerValueFactory<>(obsPropTypeList);
	Spinner<String> propertyTypeSpinner = new Spinner<String>();
	propertyTypeSpinner.setValueFactory(svf);
	Button deleteRowButton = new Button("x");
	HBox spinnerAndButtonBox = new HBox();
	spinnerAndButtonBox.setAlignment(Pos.CENTER_RIGHT);
	HBox.setHgrow(spinnerAndButtonBox, Priority.ALWAYS);
	spinnerAndButtonBox.getChildren().addAll(propertyTypeSpinner, deleteRowButton);
	unmatchedPropertyBox.getChildren().add(spinnerAndButtonBox);
	unmatchedPropertyBox.setAlignment(Pos.CENTER_LEFT);
	unmatchedPropertyBox.setPrefWidth(stage.getWidth());
	deleteRowButton.setOnAction(e_ -> {
		HBox column = (HBox) deleteRowButton.getParent();
		String matchedSource = ((Label) ((VBox) column.getChildren().get(0)).getChildren().get(0)).getText();
		String matchedTarget = ((Label) ((VBox) column.getChildren().get(1)).getChildren().get(0)).getText();
		if (matchedSource != null) {
			sourcePropList.getItems().add(matchedSource);
		}
		if (matchedTarget != null) {
			targetPropList.getItems().add(matchedTarget);
		}
		VBox row = (VBox) deleteRowButton.getParent().getParent();
		row.getChildren().remove(deleteRowButton.getParent());
	});
}
 
开发者ID:dice-group,项目名称:LIMES,代码行数:33,代码来源:MLPropertyMatchingView.java

示例10: createIntegerSpinner

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
private Spinner<Integer> createIntegerSpinner() {
    Spinner<Integer> spinner = new Spinner<>();
    spinner.setId("integer-spinner");
    spinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 50));
    return spinner;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:7,代码来源:SpinnerSample.java

示例11: configureIntegerSpinner

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
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);
}
 
开发者ID:joffrey-bion,项目名称:fx-log,代码行数:6,代码来源:PreferencesController.java

示例12: configureDoubleSpinner

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
private void configureDoubleSpinner(Spinner<Double> spinner, Property<Double> prop, double min, double max) {
    DoubleSpinnerValueFactory factory = new DoubleSpinnerValueFactory(min, max);
    factory.valueProperty().bindBidirectional(prop);
    spinner.setValueFactory(factory);
}
 
开发者ID:joffrey-bion,项目名称:fx-log,代码行数:6,代码来源:PreferencesController.java

示例13: IntegerControl

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
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);
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:43,代码来源:IntegerControl.java

示例14: createJFXNode

import javafx.scene.control.Spinner; //导入方法依赖的package包/类
@Override
protected final Spinner<String> createJFXNode() throws Exception
{
    final Spinner<String> spinner = new Spinner<String>();
    spinner.setValueFactory(createSVF());
    styleChanged(null, null, null);
    spinner.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
    if (!toolkit.isEditMode())
        spinner.setEditable(true);
    spinner.focusedProperty().addListener((property, oldval, newval)->
    {
        if (!spinner.isFocused())
            restore();
        active = false;
    });
    spinner.getEditor().setOnKeyPressed((final KeyEvent event) ->
    {
        switch (event.getCode())
        {
        case ESCAPE: //TODO: fix: escape key event not sensed
            // Revert original value, leave active state
            restore();
            active = false;
            break;
        case ENTER:
            // Submit value, leave active state
            submit();
            active = false;
            break;
        //incrementing by keyboard
        case UP:
        case PAGE_UP:
            if (!active)
                jfx_node.getValueFactory().increment(1);
            break;
        case DOWN:
        case PAGE_DOWN:
            if (!active)
                jfx_node.getValueFactory().decrement(1);
            break;
        default:
            // Any other key results in active state
            active = true;
        }
    });
    return spinner;
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:48,代码来源:SpinnerRepresentation.java


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