當前位置: 首頁>>代碼示例>>Java>>正文


Java Spinner.setEditable方法代碼示例

本文整理匯總了Java中javafx.scene.control.Spinner.setEditable方法的典型用法代碼示例。如果您正苦於以下問題:Java Spinner.setEditable方法的具體用法?Java Spinner.setEditable怎麽用?Java Spinner.setEditable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.Spinner的用法示例。


在下文中一共展示了Spinner.setEditable方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createZoomSpinner

import javafx.scene.control.Spinner; //導入方法依賴的package包/類
private Spinner<Integer> createZoomSpinner(ToggleButton btnZoom, String ip)
{
	Spinner<Integer> spinnerZoom = new Spinner<>(googleMinZoomLevel, googleMaxZoomLevel, googleDefaultZoomLevel, googleZoomLevelStep);
	spinnerZoom.setPrefWidth(55);
	spinnerZoom.setPrefHeight(btnZoom.getHeight());
	spinnerZoom.valueProperty().addListener((ChangeListener<Integer>) (observable, oldValue, newValue) ->
	{
		imgService.setCenterOnIP(ip, newValue);
		labelUnderMap.setVisible(true);

		generateAndShowImage();
	});
	Tooltip spinnerTooltip = new Tooltip("Set zoom level (1-20)");
	ToolTipUtilities.setTooltipProperties(spinnerTooltip, true, GUIController.defaultTooltipMaxWidth, GUIController.defaultFontSize, null);
	spinnerZoom.setTooltip(spinnerTooltip);
	spinnerZoom.getEditor().setTooltip(spinnerTooltip);
	spinnerZoom.setEditable(false);
	spinnerZoom.setDisable(true);
	
	return spinnerZoom;
}
 
開發者ID:ck3ck3,項目名稱:WhoWhatWhere,代碼行數:22,代碼來源:VisualTraceUI.java

示例2: initialize

import javafx.scene.control.Spinner; //導入方法依賴的package包/類
@FXML
@Override
public void initialize() {
  super.initialize();

  final Spinner<List> spinner = new Spinner<>(this.valueFactory);
  spinner.setEditable(true);
  spinner.disableProperty().bind(this.getHandle().connectedProperty());
  spinner.focusedProperty().addListener((s, ov, nv) -> {
    // Code found at http://stackoverflow.com/questions/32340476/manually-typing-in-text-in-javafx-spinner-is-not-updating-the-value-unless-user
    if (nv) {
      return;
    }
    commitEditorText(spinner);
  });
  this.setContent(spinner);
}
 
開發者ID:WPIRoboticsProjects,項目名稱:GRIP,代碼行數:18,代碼來源:ListSpinnerInputSocketController.java

示例3: 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

示例4: 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

示例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: buildOptionPane

import javafx.scene.control.Spinner; //導入方法依賴的package包/類
/**
 * Create a block of niche options - specifically International Dateline cropping and whether
 * there should be a graticule
 * @param cropAtIDL The mutable boolean value to which to bind the "Crop at Dateline" CheckBox
 * @param graticule The mutable double value to which to bind the "Graticule" Spinner
 * @return the full formatted Region
 */
protected Region buildOptionPane(Flag cropAtIDL, MutableDouble graticule) {
	final CheckBox cropBox = new CheckBox("Crop at International Dateline"); //the CheckBox for whether there should be shown imagery outside the International Dateline
	cropBox.setSelected(cropAtIDL.isSet());
	cropBox.setTooltip(new Tooltip("Show every point exactly once."));
	cropBox.selectedProperty().addListener((observable, old, now) -> {
			cropAtIDL.set(now);
		});
	
	final ObservableList<Double> factorsOf90 = FXCollections.observableArrayList();
	for (double f = 1; f <= 90; f += 0.5)
		if (90%f == 0)
			factorsOf90.add((double)f);
	final Spinner<Double> gratSpinner = new Spinner<Double>(factorsOf90); //spinner for the graticule value
	gratSpinner.getValueFactory().setConverter(new DoubleStringConverter());
	gratSpinner.getValueFactory().setValue(graticule.get());
	gratSpinner.setDisable(graticule.isZero());
	gratSpinner.setEditable(true);
	gratSpinner.setTooltip(new Tooltip("The spacing in degrees between shown parallels and meridians."));
	gratSpinner.setPrefWidth(SPINNER_WIDTH);
	gratSpinner.valueProperty().addListener((observable, old, now) -> {
			graticule.set(now); //which is tied to the mutable graticule spacing variable
		});
	
	final CheckBox gratBox = new CheckBox("Graticule: "); //the CheckBox for whether there should be a graticule
	gratBox.setSelected(!graticule.isZero());
	gratBox.setTooltip(new Tooltip("Overlay a mesh of parallels and meridians."));
	gratBox.selectedProperty().addListener((observable, old, now) -> {
			if (now)
				graticule.set(gratSpinner.getValue()); //set the value of graticule appropriately when checked
			else
				graticule.set(0); //when not checked, represent "no graticule" as a spacing of 0
			gratSpinner.setDisable(!now); //disable the graticule Spinner when appropriate
		});
	
	final HBox gratRow = new HBox(H_SPACE, gratBox, gratSpinner);
	gratRow.setAlignment(Pos.CENTER_LEFT);
	return new VBox(V_SPACE, cropBox, gratRow);
}
 
開發者ID:jkunimune15,項目名稱:Map-Projections,代碼行數:46,代碼來源:MapApplication.java

示例7: createYearSelector

import javafx.scene.control.Spinner; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:ivartanian,項目名稱:JVx.javafx,代碼行數:15,代碼來源:FXDateTimePickerSkin.java

示例8: createSpinner

import javafx.scene.control.Spinner; //導入方法依賴的package包/類
/**
 * Creates a default {@link Spinner}.
 * 
 * @param pStyleClassName the class name used for styling.
 * @param pMinValue the minimum value.
 * @param pMaxValue the maximum value.
 * @return the {@link Spinner}.
 */
protected Spinner<Integer> createSpinner(String pStyleClassName, int pMinValue, int pMaxValue)
{
	Spinner<Integer> spinner = new FXSpinnerRT40623<>(pMinValue, pMaxValue, pMinValue);
	spinner.getEditor().setAlignment(Pos.CENTER_RIGHT);
	spinner.getStyleClass().add(pStyleClassName);
	spinner.getStylesheets().add(FXTimePicker.DEFAULT_STYLE);
	spinner.getValueFactory().setWrapAround(true);
	spinner.setEditable(true);
	spinner.valueProperty().addListener(this::onSpinnerValueChanged);
	
	return spinner;
}
 
開發者ID:ivartanian,項目名稱:JVx.javafx,代碼行數:21,代碼來源:FXTimePickerSkin.java

示例9: 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

示例10: addNumberParameterHBox

import javafx.scene.control.Spinner; //導入方法依賴的package包/類
/**
    * creates a {@link javafx.scene.layout.HBox} with the information from the
    * learning parameter if it is a Integer or Double
    * 
    * @param param
    * @param root
    * @param position
    * @param integer
    */
   private void addNumberParameterHBox(LearningParameter param, GridPane root, int position) {

String type = param.getClazz().getSimpleName().toString().toLowerCase().trim();
Label parameterText = new Label(param.getName());
Spinner parameterSpinner = null;
int intStep = 1;
double doubleStep = 0.01;
if (!Double.isNaN(param.getRangeStep())) {
    intStep = (int) param.getRangeStep();
    doubleStep = Double.valueOf(param.getRangeStep());
}
switch (type) {
case "integer":
    parameterSpinner = new Spinner<Integer>((int) param.getRangeStart(), (int) param.getRangeEnd(), (int) param.getValue(), intStep);
    break;
case "double":
    parameterSpinner = new Spinner<Double>(param.getRangeStart(), param.getRangeEnd(), (double) param.getValue(), doubleStep);
    break;
case "float":
    parameterSpinner = new Spinner<Double>(Double.valueOf(param.getRangeStart()), Double.valueOf(param.getRangeEnd()), Double.valueOf(param.getValue()
	    .toString()), doubleStep);
    break;
default:
    // in case it's a too big long
    int rangeEnd = (param.getRangeEnd() < Integer.MAX_VALUE) ? (int) param.getRangeEnd() : Integer.MAX_VALUE;
    parameterSpinner = new Spinner<Integer>((int) param.getRangeStart(), rangeEnd, Integer.valueOf(param.getValue().toString()), intStep);
    break;
}
parameterSpinner.setEditable(true);
root.add(parameterText, 0, position);
root.add(parameterSpinner, 1, position);
   }
 
開發者ID:dice-group,項目名稱:LIMES,代碼行數:42,代碼來源:MachineLearningView.java

示例11: getNewStop

import javafx.scene.control.Spinner; //導入方法依賴的package包/類
private Stop getNewStop ( Stop previous ) {

        Dialog<Stop> dialog = new Dialog<>();

        dialog.setTitle("Stop Editor");
        dialog.setHeaderText(previous == null ? "Define a new Stop" : "Edit the selected Stop");
        dialog.getDialogPane().getButtonTypes().addAll(OK, CANCEL);

        Spinner<Double> offsetSpinner = new Spinner<>(0.0, 1.0, previous == null ? 0.0 : previous.getOffset(), 0.01);
        ColorPicker colorPicker = new ColorPicker(previous == null ? Color.GOLDENROD : previous.getColor());
        GridPane grid = new GridPane();

        offsetSpinner.setEditable(true);
        offsetSpinner.setPrefWidth(USE_COMPUTED_SIZE);
        colorPicker.setPrefWidth(USE_COMPUTED_SIZE);

        grid.setHgap(6);
        grid.setVgap(12);
        grid.setPadding(new Insets(12, 12, 12, 12));
        grid.getColumnConstraints().add(0, new ColumnConstraints(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, Priority.ALWAYS, HPos.RIGHT, true));
        grid.getColumnConstraints().add(1, new ColumnConstraints(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, Priority.ALWAYS, HPos.LEFT, true));
        grid.add(new Label("Offset:"), 0, 0);
        grid.add(offsetSpinner, 1, 0);
        grid.add(new Label("Color:"), 0, 1);
        grid.add(colorPicker, 1, 1);

        dialog.initOwner(stopsTable.getScene().getWindow());
        dialog.getDialogPane().getScene().getStylesheets().add("/styles/dark-style.css");
        dialog.getDialogPane().setContent(grid);
        dialog.setResultConverter(b -> {
            if ( b == OK ) {
                return new Stop(offsetSpinner.getValue(), colorPicker.getValue());
            } else {
                return null;
            }
        });

        Platform.runLater(() -> offsetSpinner.requestFocus());

        return dialog.showAndWait().orElse(null);

    }
 
開發者ID:ESSICS,項目名稱:KNOBS,代碼行數:43,代碼來源:StopListEditorController.java

示例12: 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

示例13: 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

示例14: makeEditableSafely

import javafx.scene.control.Spinner; //導入方法依賴的package包/類
/**
 * Makes the spinner editable. Ensures that the values will be committed when focus is lost.
 *
 * @param defaultValue The value to use if nothing is entered
 * @param <T>          The number type of the spinner
 */
@SuppressWarnings("PMD.IfElseStmtsMustUseBraces")
public static <T extends Number> void makeEditableSafely(Spinner<T> spinner, NumberFormat
    format, T defaultValue) {
  spinner.setEditable(true);

  TextField editor = spinner.getEditor();

  // Override the converter used to interpret editor values.  If there's an error, we want to
  // set the default
  // value instead of throwing an exception.
  StringConverter<T> oldConverter = spinner.getValueFactory().getConverter();
  spinner.getValueFactory().setConverter(new StringConverter<T>() {
    @Override
    public String toString(T t) {
      return oldConverter.toString(t);
    }

    @Override
    public T fromString(String s) {
      return Optional.ofNullable(oldConverter.fromString(s)).orElse(defaultValue);
    }
  });

  // Commit the spinner value when the editor loses focus
  editor.focusedProperty().addListener((s, ov, focused) -> {
    if (!focused) {
      SpinnerValueFactory<T> valueFactory = spinner.getValueFactory();
      StringConverter<T> converter = valueFactory.getConverter();
      valueFactory.setValue(converter.fromString(editor.getText()));
    }
  });

  // Filter out invalid editor changes
  editor.setTextFormatter(new TextFormatter<T>(change -> {
    if (change.isContentChange() && !change.getControlNewText().isEmpty()) {
      ParsePosition position = new ParsePosition(0);
      format.parse(change.getControlNewText(), position);

      if (position.getIndex() == 0 || position.getIndex() < change.getControlNewText().length()) {
        return null;
      }
    }

    return change;
  }));
}
 
開發者ID:WPIRoboticsProjects,項目名稱:GRIP,代碼行數:53,代碼來源:Spinners.java


注:本文中的javafx.scene.control.Spinner.setEditable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。