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


Java Spinner.setPrefWidth方法代码示例

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


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

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

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

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

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


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