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


Java Toggle类代码示例

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


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

示例1: TypedToggleGroup

import javafx.scene.control.Toggle; //导入依赖的package包/类
public TypedToggleGroup() {

		this.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
			@Override
			@SuppressWarnings("unchecked")
			public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
				if (newValue != null) {
					T obj = (T) newValue.getUserData();
					selectedValueProperty.setValue(obj);
				} else {
					selectedValueProperty.setValue(null);
				}
			}
		});

	}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:17,代码来源:TypedToggleGroup.java

示例2: getSecretValue

import javafx.scene.control.Toggle; //导入依赖的package包/类
private SecretValue getSecretValue(ToggleGroup valueSource, String value, String generated, File file) {
    Toggle current = valueSource.getSelectedToggle();

    String secretString;
    if (current.getUserData().equals("value")) {
        secretString = value;
    } else if (current.getUserData().equals("generated")) {
        Integer numBytesToGenerate = Integer.valueOf(generated);
        // TODO: store as plain bytes?
        byte[] random = Singleton.randomGenerator.generateRandom(numBytesToGenerate);
        secretString = Base64.encodeAsString(random);
    } else {
        String path = null;
        try {
            path = file.getCanonicalPath();
            return SecretValueConverter.inferEncoding(Files.readAllBytes(Paths.get(path)), SecretType.OPAQUE);
        } catch (IOException e) {
            throw new RuntimeException("Failed to read secret from file");
        }
    }

    return new SecretValue(secretString, SecretType.OPAQUE);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:24,代码来源:GetNewSecret.java

示例3: initialize

import javafx.scene.control.Toggle; //导入依赖的package包/类
@Override
public void initialize(URL arg0, ResourceBundle arg1) {

	final Image tempImage = new Image(getClass().getResourceAsStream("/images/Valencia.jpg"));
	tempimg.setImage(tempImage);

	temprb.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
		public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
			if (temprb.getSelectedToggle() != null) {
				RadioButton chk = (RadioButton) old_toggle.getToggleGroup().getSelectedToggle();
				System.out.println("Selected Radio Button - " + chk.getText());
				final Image image = new Image(
						getClass().getResourceAsStream("/images/" + chk.getText().toString() + ".jpg"
				// Cast object to radio button
				// System.out.println("Selected Radio Button -
				// "+chk.getText());

				));
				tempimg.setImage(image);
			}
		}
	});
}
 
开发者ID:djdivix,项目名称:IDBuilderFX,代码行数:24,代码来源:TemplateController.java

示例4: TemplateField

import javafx.scene.control.Toggle; //导入依赖的package包/类
public TemplateField(String name, String label, boolean isSelected, String constant) {
  this.name = name;
  this.label = label;
  this.isSelected = isSelected;
  this.selection = "YES";
  this.value = constant;

  labelElement = new WikiLabel(label).setWidth(200, 500).setHeight(35);
  buttonYes.setSelected(true);

  group.selectedToggleProperty().addListener((ObservableValue<? extends Toggle> ov, Toggle tOld, Toggle tNew) -> {
    RadioButton btn = (RadioButton) tNew.getToggleGroup().getSelectedToggle();
    setSelection(btn.getId());
  });

  valueText.setOnKeyReleased((KeyEvent event) -> {
    this.value = valueText.getText();
  });
}
 
开发者ID:yarl,项目名称:pattypan,代码行数:20,代码来源:TemplateField.java

示例5: changed

import javafx.scene.control.Toggle; //导入依赖的package包/类
@Override
public void changed(ObservableValue<? extends Toggle> pObservableValue, Toggle pOld, Toggle pNew)
{
	if( aScene != null )
	{
		aScene.getStylesheets().clear();
		switch(aSkin.getSelectedToggle().getUserData().toString())
		{
		case "Floral":
			aScene.getStylesheets().add(Welcome.class.getResource("cs1.css").toExternalForm());
			break;
			
		case "Chintz":
			aScene.getStylesheets().add(Welcome.class.getResource("cs2.css").toExternalForm());
			break;

		default:
			break;
		}
		
	}
}
 
开发者ID:prmr,项目名称:COMP303Starter,代码行数:23,代码来源:Welcome.java

示例6: removeButton

import javafx.scene.control.Toggle; //导入依赖的package包/类
public void removeButton(T ref) {
	if (!items.containsKey(ref)) {
		logger.error("removeButton on non-existing ref - {}", ref);
		return;
	}

	final Node item = items.remove(ref);

	if (Platform.isFxApplicationThread()) {
		subContainer.getChildren().remove(item);
	} else {
		Platform.runLater(() -> subContainer.getChildren().remove(item));
	}

	if (toggleable && ref == defaultSelection) {
		defaultSelection = null;
	}

	if (toggleable && ref == currentSelection && defaultSelection != null) {
		currentSelection = defaultSelection;
		itemListener.onItemClicked(currentSelection);
		toggleGroup.selectToggle((Toggle) items.get(currentSelection));
	}
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:25,代码来源:ItemSelectionPane.java

示例7: getOpenDisplayAction

import javafx.scene.control.Toggle; //导入依赖的package包/类
/** @return {@link OpenDisplayActionInfo} from sub pane */
private OpenDisplayActionInfo getOpenDisplayAction()
{
    Target target = Target.REPLACE;
    List<Toggle> modes = open_display_targets.getToggles();
    for (int i=0; i<modes.size(); ++i)
        if (modes.get(i).isSelected())
        {
            target = Target.values()[i];
            break;
        }

    return new OpenDisplayActionInfo(open_display_description.getText(),
                                     open_display_path.getText().trim(),
                                     open_display_macros.getMacros(),
                                     target);
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:18,代码来源:ActionsDialog.java

示例8: initialize

import javafx.scene.control.Toggle; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
    closeJarButton.setDisable(Main.getLoadedJar() == null);
    loadMappingsButton.setDisable(Main.getLoadedJar() == null);
    mergeMappingsButton.setDisable(Main.getLoadedJar() == null);
    saveMappingsButton.setDisable(Main.getLoadedJar() == null);
    saveMappingsAsButton.setDisable(Main.getLoadedJar() == null);
    resetMappingsButton.setDisable(Main.getLoadedJar() == null);

    final String langRadioPrefix = "langRadio-";
    for (Toggle toggle : languageGroup.getToggles()) {
        if (((RadioMenuItem) toggle).getId().equals(langRadioPrefix + Main.getCurrentLocale())) {
            toggle.setSelected(true);
            break;
        }
    }

    setAccelerators();

    this.initTreeViews();

    RESTART_ALERT.setTitle(Main.getResourceBundle().getString("dialog.restart.title"));
    RESTART_ALERT.setHeaderText(null);
    RESTART_ALERT.setContentText(Main.getResourceBundle().getString("dialog.restart.content"));
}
 
开发者ID:LapisBlue,项目名称:Nocturne,代码行数:26,代码来源:MainController.java

示例9: setValidationSupport

import javafx.scene.control.Toggle; //导入依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<Toggle> operationValidator = (c, newValue) -> {
		String whyBad = null;
		if (newValue != null) {
			String nameOfOperator = ((ToggleButton) newValue).getText();
			BooleanOperator operator = BooleanOperator.valueOf(nameOfOperator);
			if (logicalChecker != null) {
				// Internally the result will depend on amount of children.
				whyBad = logicalChecker
						.whyOperatorCantBeAppliedToCurrentAmountOfCheckers(operator);
			}
		}
		ValidationResult wrongResult = ValidationResult.fromErrorIf(c,
				whyBad, whyBad != null);
		if (newValue != null) {
			ToggleButton origTB = mapWithButtons.get(origLogicalChecker.getOperator().name());
			buttonStateManager.reportNewValueOfControl(origTB, newValue, c, wrongResult);
		}
		return wrongResult;
	};
	this.validationSupport.registerValidator(segmentedButton, operationValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:25,代码来源:LogicalCheckerController.java

示例10: initialize

import javafx.scene.control.Toggle; //导入依赖的package包/类
public void initialize() {
    //init values
    mExpanded = new SimpleBooleanProperty(true);
    mSelectedButton = new SimpleObjectProperty<>(SideButton.NONE);

    //minimize the side pane
    handleMenuButtonAction();

    //add toggle listener
    sideButton.selectedToggleProperty().addListener(
            (ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) -> {
                if (newValue != null) {
                    selectedButtonChanged((ToggleButton) newValue);
                } else {
                    oldValue.setSelected(true);
                }
            });
}
 
开发者ID:dipu-bd,项目名称:Cymric,代码行数:19,代码来源:SidePane.java

示例11: ToggleButtonSample

import javafx.scene.control.Toggle; //导入依赖的package包/类
public ToggleButtonSample() {
    // create label to show result of selected toggle button
    final Label label = new Label();
    label.setStyle("-fx-font-size: 2em;");
    // create 3 toggle buttons and a toogle group for them
    final ToggleButton tb1 = new ToggleButton("Cat");
    final ToggleButton tb2 = new ToggleButton("Dog");
    final ToggleButton tb3 = new ToggleButton("Horse");
    ToggleGroup group = new ToggleGroup();
    tb1.setToggleGroup(group);
    tb2.setToggleGroup(group);
    tb3.setToggleGroup(group);
    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) {
            if(selectedToggle!=null) {
                label.setText(((ToggleButton) selectedToggle).getText());
            }
            else {
                label.setText("...");
            }
        }
    });
    // select the first button to start with
    group.selectToggle(tb1);
    // add buttons and label to grid and set their positions
    GridPane.setConstraints(tb1,0,0);
    GridPane.setConstraints(tb2,1,0);
    GridPane.setConstraints(tb3,2,0);
    GridPane.setConstraints(label,0,1,3,1);
    GridPane grid = new GridPane();
    grid.setVgap(20);
    grid.setHgap(10);
    getChildren().add(grid);
    grid.getChildren().addAll(tb1, tb2, tb3, label);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:36,代码来源:ToggleButtonSample.java

示例12: start

import javafx.scene.control.Toggle; //导入依赖的package包/类
@Override
public void start(Stage stage) {
    stage.setTitle("Toggle Button Sample");
    stage.setWidth(250);
    stage.setHeight(180);
    
    HBox hbox = new HBox();
    VBox vbox = new VBox();        
    
    Scene scene = new Scene(new Group(vbox));
    stage.setScene(scene);
    scene.getStylesheets().add("togglebuttonsample/ControlStyle.css");

    Rectangle rect = new Rectangle();
    rect.setHeight(50);
    rect.setFill(Color.WHITE);
    rect.setStroke(Color.DARKGRAY);
    rect.setStrokeWidth(2);
    rect.setArcHeight(10);
    rect.setArcWidth(10);

    final ToggleGroup group = new ToggleGroup();

    group.selectedToggleProperty().addListener(
        (ObservableValue<? extends Toggle> ov, 
        Toggle toggle, Toggle new_toggle) -> {
        if (new_toggle == null)
            rect.setFill(Color.WHITE);
        else
            rect.setFill((Color) group.getSelectedToggle().getUserData());
    });

    ToggleButton tb1 = new ToggleButton("Minor");
    tb1.setToggleGroup(group);
    tb1.setUserData(Color.LIGHTGREEN);
    tb1.setSelected(true);
    tb1.getStyleClass().add("toggle-button1");

    ToggleButton tb2 = new ToggleButton("Major");
    tb2.setToggleGroup(group);
    tb2.setUserData(Color.LIGHTBLUE);
    tb2.getStyleClass().add("toggle-button2");

    ToggleButton tb3 = new ToggleButton("Critical");
    tb3.setToggleGroup(group);
    tb3.setUserData(Color.SALMON);
    tb3.getStyleClass().add("toggle-button3");

    

    hbox.getChildren().addAll(tb1, tb2, tb3);

    vbox.getChildren().add(new Label("Priority:"));
    vbox.getChildren().add(hbox);
    vbox.getChildren().add(rect);
    vbox.setPadding(new Insets(20, 10, 10, 20));

          
    stage.show();
    rect.setWidth(hbox.getWidth());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:62,代码来源:ToggleButtonSample.java

示例13: addToggleGroup

import javafx.scene.control.Toggle; //导入依赖的package包/类
/**
 * Add an enumeration of options to a wizard step. Multiple RadioButtons
 * will be used (horizontally-aligned).
 *
 * @param fieldName
 * @param options
 *            list of choices.
 * @param prompt
 *            the text to show on the buttons tooltip.
 * @param defaultValue
 *            the default value to be selected.
 * @return
 */
@SuppressWarnings("unchecked")
public WizardStepBuilder addToggleGroup(final String fieldName, final String[] options, final String[] prompt,
        final int defaultValue)
{
    final ToggleGroup group = new ToggleGroup();

    final HBox box = new HBox();

    for (int i = 0; i < options.length; i++)
    {
        final JFXRadioButton radio = new JFXRadioButton(options[i]);
        radio.setPadding(new Insets(10));
        radio.setToggleGroup(group);
        radio.setTooltip(new Tooltip(prompt[i]));
        radio.setUserData(options[i]);
        if (i == defaultValue)
            radio.setSelected(true);

        box.getChildren().add(radio);
    }

    this.current.getData().put(fieldName, new ReadOnlyObjectWrapper<Toggle>());
    this.current.getData().get(fieldName).bind(group.selectedToggleProperty());
    final Label label = new Label(fieldName);
    GridPane.setHalignment(label, HPos.RIGHT);
    GridPane.setHalignment(box, HPos.LEFT);
    this.current.add(label, 0, this.current.getData().size() - 1);
    this.current.add(box, 1, this.current.getData().size() - 1);
    return this;
}
 
开发者ID:Leviathan-Studio,项目名称:MineIDE,代码行数:44,代码来源:WizardStepBuilder.java

示例14: getPlacementToggle

import javafx.scene.control.Toggle; //导入依赖的package包/类
public  boolean getPlacementToggle() {
	Toggle in = placementToggleGroup.getSelectedToggle();
	boolean out = false;
	if(in == activePlace) out = true;
	
	return out;
}
 
开发者ID:X-Cats,项目名称:Scout2017,代码行数:8,代码来源:PitIntController.java

示例15: initialize

import javafx.scene.control.Toggle; //导入依赖的package包/类
@FXML
void initialize() {
    if (Language.RO.equals(langCtr.getLanguage())) {
        engRadio.setSelected(false);
        romRadio.setSelected(true);
    }
    langGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
            changeLanguage();
        }
    });
}
 
开发者ID:stancalau,项目名称:springfx,代码行数:13,代码来源:FirstPresentation.java


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