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


Java RadioButton类代码示例

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


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

示例1: createRadioButton

import javafx.scene.control.RadioButton; //导入依赖的package包/类
private RadioButton createRadioButton(final Node rect, String name, final boolean toFront, ToggleGroup tg) {
    final RadioButton radioButton = new RadioButton(name);
    radioButton.setToggleGroup(tg);
    radioButton.selectedProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (radioButton.isSelected()) {
                if (toFront) {
                    rect.toFront();
                } else {
                    rect.toBack();
                }
            }
        }
    });

    return radioButton;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:NodePropertiesSample.java

示例2: RadioButtons

import javafx.scene.control.RadioButton; //导入依赖的package包/类
public RadioButtons() {
    super(400,100);
    ToggleGroup tg = new ToggleGroup();
    VBox vbox = new VBox();
    vbox.setSpacing(5);
    RadioButton rb1 = new RadioButton("Hello");
    rb1.setToggleGroup(tg);

    RadioButton rb2 = new RadioButton("Bye");
    rb2.setToggleGroup(tg);
    rb2.setSelected(true);

    RadioButton rb3 = new RadioButton("Disabled");
    rb3.setToggleGroup(tg);
    rb3.setSelected(false);
    rb3.setDisable(true);

    vbox.getChildren().add(rb1);
    vbox.getChildren().add(rb2);
    vbox.getChildren().add(rb3);
    getChildren().add(vbox);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:23,代码来源:RadioButtons.java

示例3: selectRadioButtonNotSelected

import javafx.scene.control.RadioButton; //导入依赖的package包/类
@Test public void selectRadioButtonNotSelected() {
    RadioButton radioButton = (RadioButton) getPrimaryStage().getScene().getRoot().lookup(".radio-button");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXToggleButton rfxToggleButton = new RFXToggleButton(radioButton, null, null, lr);
            radioButton.setSelected(false);
            rfxToggleButton.mouseEntered(null);
            radioButton.setSelected(true);
            rfxToggleButton.mouseClicked(null);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", select.getCall());
    AssertJUnit.assertEquals("true", select.getParameters()[0]);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:RFXToggleButtonTest.java

示例4: getText

import javafx.scene.control.RadioButton; //导入依赖的package包/类
@Test public void getText() {
    RadioButton radioButton = (RadioButton) getPrimaryStage().getScene().getRoot().lookup(".radio-button");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXToggleButton rfxToggleButton = new RFXToggleButton(radioButton, null, null, lr);
            radioButton.setSelected(false);
            rfxToggleButton.mouseEntered(null);
            radioButton.setSelected(true);
            rfxToggleButton.mouseClicked(null);
            text.add(rfxToggleButton._getText());
        }
    });
    new Wait("Waiting for toggle button text") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Hello", text.get(0));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:22,代码来源:RFXToggleButtonTest.java

示例5: createButtonGroup

import javafx.scene.control.RadioButton; //导入依赖的package包/类
/**
 * Create a radio button for each String in the list, add them to the container, and bind the selected value to the
 * String property
 *
 * @param container     Container to put radio buttons in
 * @param radioBtns     List of Strings, one for each radio button
 * @param modelProperty Property to bind selected radio button's value to
 */
public static ToggleGroupValue createButtonGroup(Pane container, List<String> radioBtns, StringProperty modelProperty) {
    // Create new ToggleGroup and ToggleGroupValue for the radio buttons
    ToggleGroupValue groupValue = new ToggleGroupValue();
    ToggleGroup btnsGroup = new ToggleGroup();

    // Create a radio button for each option
    for (String s : radioBtns) {
        // Create radio button for this option
        RadioButton radioBtn = new RadioButton(s);
        radioBtn.setUserData(s);
        radioBtn.setToggleGroup(btnsGroup);

        // Add to RadioButton to the container pane and the ToggleGroupValue
        container.getChildren().add(radioBtn);
        groupValue.add(radioBtn, radioBtn.getUserData());
    }

    // Bind toggle group value to model
    modelProperty.bindBidirectional(groupValue.valueProperty());

    // Select first option
    groupValue.setValue(radioBtns.get(0));

    return groupValue;
}
 
开发者ID:scify,项目名称:jedai-ui,代码行数:34,代码来源:RadioButtonHelper.java

示例6: initialize

import javafx.scene.control.RadioButton; //导入依赖的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

示例7: makeDataSelector

import javafx.scene.control.RadioButton; //导入依赖的package包/类
/**
 * Data selector between VoogaBoolean and VoogaNumber.
 * @return
 */
private HBox makeDataSelector () {
	ToggleGroup group = new ToggleGroup();
	RadioButton number = new RadioButton("Number");
	number.setToggleGroup(group);
	number.setSelected(true);
	RadioButton bool = new RadioButton("Boolean");
	bool.setToggleGroup(group);
	number.selectedProperty().addListener( (obs, old, newVal) -> {
		container.getChildren().remove(buttons);
		if (newVal) {
			container.getChildren().add(numberSelector);
			container.getChildren().remove(boolSelector);
			chosenData = VOOGA_NUMBER;
		}
		else {
			container.getChildren().remove(numberSelector);
			container.getChildren().add(boolSelector);
			chosenData = VOOGA_BOOLEAN;
		}
		container.getChildren().add(buttons);
	});
	return GUIUtils.makeRow(number, bool);
}
 
开发者ID:sjain28,项目名称:Game-Engine-Vooga,代码行数:28,代码来源:PropertyBuilder.java

示例8: ItemListCell

import javafx.scene.control.RadioButton; //导入依赖的package包/类
ItemListCell() {
	hBox = new HBox();
	rd = new RadioButton();

	rd.setOnMouseClicked(ev -> {
		getListView().getItems().forEach(v -> v.setSelection(false));
		CodeItem codeItem = getListView().getItems().get(ItemListCell.this.getIndex());
		codeItem.setSelection(true);
		selectedItem.set(codeItem);
		rd.setSelected(true);
	});

	rd.setToggleGroup(value);
	label = new Label();
	hBox.getChildren().addAll(rd, label);
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:17,代码来源:InjectionItemListComposite.java

示例9: SessionConflictDialog

import javafx.scene.control.RadioButton; //导入依赖的package包/类
public SessionConflictDialog( Session scheduled, Session proposed, SessionVisuals sessionVisuals  ){
    this.rootNode.getStyleClass().add("session-conflict-dialog");

    this.sessionVisuals = sessionVisuals;

    setTitle(new Label(OTNBundle.getString("OTN.CONFLICT.SCHEDULE_CONFLICT")));

    RadioButton rbScheduled = new RadioButton(OTNBundle.getString("OTN.CONFLICT.CURRENTLY_SCHEDULED"));
    RadioButton rbProposed = new RadioButton(OTNBundle.getString("OTN.CONFLICT.PROPOSED"));

    ToggleGroup group = new ToggleGroup();
    group.getToggles().addAll(rbScheduled, rbProposed);
    group.selectToggle(rbScheduled);
    
    final VBox vBox = new VBox(
            new Label(OTNBundle.getString("OTN.CONFLICT.QUESTION")),
            sessionPane(scheduled, rbScheduled),
            sessionPane(proposed, rbProposed));
    vBox.getStyleClass().add("content");

    setContent(vBox);

    getButtons().addAll(
            createButton(OTNBundle.getString("OTN.BUTTON.CANCEL"),   () -> null),
            createButton(OTNBundle.getString("OTN.BUTTON.SCHEDULE"), () -> rbProposed.isSelected() ? proposed: scheduled));
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:27,代码来源:SessionConflictDialog.java

示例10: TemplateField

import javafx.scene.control.RadioButton; //导入依赖的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

示例11: setText

import javafx.scene.control.RadioButton; //导入依赖的package包/类
@Override
protected void setText ()
{
  RadioButton selectedFileButton = (RadioButton) grpFileName.getSelectedToggle ();
  if (selectedFileButton == null)
  {
    eraseCommand ();
    return;
  }

  RadioButton selectedSpaceUnitsButton =
      (RadioButton) grpSpaceUnits.getSelectedToggle ();
  RadioButton selectedDispositionButton =
      (RadioButton) grpDisposition.getSelectedToggle ();

  tsoCommand.txtCommand
      .setText (((TextField) selectedFileButton.getUserData ()).getText ());
  setButton ();
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:20,代码来源:TransfersTab.java

示例12: getJson

import javafx.scene.control.RadioButton; //导入依赖的package包/类
@Override
public JSONObject getJson() {
    JSONObject obj = new JSONObject();
    System.out.println(getLayoutX());
    System.out.println(getLayoutY());
    obj.put("layoutX", getLayoutX());
    obj.put("layoutY", getLayoutY());
    obj.put("type", "component");
    obj.put("id", getId());
    obj.put("name", getName());
    List<String> radioGroupNames = new ArrayList<>();
    radioGroupNames.add("squareRadio");
    radioGroupNames.add("sawtoothRadio");
    radioGroupNames.add("triangleRadio");
    radioGroupNames.add("sineRadio");
    radioGroupNames.forEach(s -> {
        getChildren().forEach(node -> {
            if (node.getId() != null && node.getId().equals(s)) {
                obj.put(s, ((RadioButton) node).isSelected());
            }
        });
    });
    return obj;
}
 
开发者ID:StephaneMangin,项目名称:Synth,代码行数:25,代码来源:ComponentPane.java

示例13: impl_drawNode

import javafx.scene.control.RadioButton; //导入依赖的package包/类
@Override
public Node impl_drawNode() {
    try {
        vb = FXMLLoader.load(resource);
    } catch (Exception e) {
        System.out.println("message: " + e.getMessage());
        reportGetterFailure("exception thrown.");
    }
LinkedList<ToggleGroup> toggleGroups = new LinkedList<ToggleGroup>();
for(Node child: vb.getChildren())
{
toggleGroups.add(((RadioButton) child).getToggleGroup());
}
for(int i = 0; i < toggleGroups.size() - 2; i ++)
{
if(!toggleGroups.get(i).equals(toggleGroups.get(i + 1)))
{
    reportGetterFailure("failed.");
    return redRectangle;
}
}
    return retRec;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:24,代码来源:staticPropertyLoadApp.java

示例14: before

import javafx.scene.control.RadioButton; //导入依赖的package包/类
@Override
@Before
public void before()
{
    super.before();
    System.out.println("fx: " + VersionInfo.getRuntimeVersion());
    firstDTest = byID(getScene(), "first_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    secondDTest = byID(getScene(), "second_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    parentDTest = byID(getScene(), "parent_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    firstNodeCombo = byID(getScene(), "first_node_combo", ComboBox.class).as(ComboBoxWrap.class);
    secondNodeCombo = byID(getScene(), "second_node_combo", ComboBox.class).as(ComboBoxWrap.class);
    firstToFront = byID(getScene(), "first_node_to_front", RadioButton.class).as(ToggleButtonWrap.class);
    secondToFront = byID(getScene(), "second_node_to_front", RadioButton.class).as(ToggleButtonWrap.class);
    indicator = byID(getScene(), "indicator", Shape.class);
    referenceGreen = byID(getScene(), "reference_green", Shape.class);
    referenceRed = byID(getScene(), "reference_red", Shape.class);
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:18,代码来源:DepthTestTest.java

示例15: enumChoiceBox

import javafx.scene.control.RadioButton; //导入依赖的package包/类
private <T extends Enum> VBox enumChoiceBox(final Class<T> enumClass, final Enum currentValue) {
    final T[] values = enumClass.getEnumConstants();
    
    final List<RadioButton> buttons = new ArrayList<>();
    final ToggleGroup toggleGroup = new ToggleGroup();
    for (T value : values) {
        final RadioButton button = new RadioButton(value.toString());
        button.setToggleGroup(toggleGroup);
        button.setSelected(value.equals(currentValue));
        
        buttons.add(button);
    }

    final VBox result = new VBox();
    result.setSpacing(10.0);
    result.getChildren().addAll(buttons);

    return result;
}
 
开发者ID:ThomasDaheim,项目名称:GPXEditor,代码行数:20,代码来源:GPXPreferencesUI.java


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