當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。