Java Code Examples for javafx.scene.control.RadioButton

The following are top voted examples for showing how to use javafx.scene.control.RadioButton. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: marathonv5   File: NodePropertiesSample.java   View source code 6 votes vote down vote up
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;
}
 
Example 2
Project: marathonv5   File: RadioButtons.java   View source code 6 votes vote down vote up
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);
}
 
Example 3
Project: marathonv5   File: NodePropertiesSample.java   View source code 6 votes vote down vote up
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;
}
 
Example 4
Project: marathonv5   File: RadioButtons.java   View source code 6 votes vote down vote up
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);
}
 
Example 5
Project: marathonv5   File: RFXToggleButtonTest.java   View source code 6 votes vote down vote up
@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]);
}
 
Example 6
Project: marathonv5   File: RFXToggleButtonTest.java   View source code 6 votes vote down vote up
@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));
}
 
Example 7
Project: jedai-ui   File: RadioButtonHelper.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 8
Project: IDBuilderFX   File: TemplateController.java   View source code 6 votes vote down vote up
@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);
			}
		}
	});
}
 
Example 9
Project: Game-Engine-Vooga   File: PropertyBuilder.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 10
Project: Gargoyle   File: InjectionItemListComposite.java   View source code 6 votes vote down vote up
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);
}
 
Example 11
Project: javaone2016   File: SessionConflictDialog.java   View source code 6 votes vote down vote up
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));
}
 
Example 12
Project: pattypan   File: TemplateField.java   View source code 6 votes vote down vote up
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();
  });
}
 
Example 13
Project: xframium-java   File: TransfersTab.java   View source code 6 votes vote down vote up
@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 ();
}
 
Example 14
Project: Synth   File: ComponentPane.java   View source code 6 votes vote down vote up
@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;
}
 
Example 15
Project: openjfx-8u-dev-tests   File: staticPropertyLoadApp.java   View source code 6 votes vote down vote up
@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;
}
 
Example 16
Project: openjfx-8u-dev-tests   File: DepthTestTest.java   View source code 6 votes vote down vote up
@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);
}
 
Example 17
Project: GPXEditor   File: GPXPreferencesUI.java   View source code 6 votes vote down vote up
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;
}
 
Example 18
Project: UCSDGraphs   File: MapApp.java   View source code 6 votes vote down vote up
private LinkedList<RadioButton> setupToggle(ToggleGroup group) {

		// Use Dijkstra as default
		RadioButton rbD = new RadioButton("Dijkstra");
		rbD.setUserData("Dijkstra");
		rbD.setSelected(true);

		RadioButton rbA = new RadioButton("A*");
		rbA.setUserData("A*");

		RadioButton rbB = new RadioButton("BFS");
		rbB.setUserData("BFS");

		rbB.setToggleGroup(group);
		rbD.setToggleGroup(group);
		rbA.setToggleGroup(group);
		return new LinkedList<RadioButton>(Arrays.asList(rbB, rbD, rbA));
	}
 
Example 19
Project: SynchronizedMediaPlayer   File: ModeSelectorViewJfx.java   View source code 6 votes vote down vote up
public ModeSelectorViewJfx() {
    hBox = new HBox(25);
    hBox.setMaxHeight(40);
    hBox.setAlignment(Pos.CENTER_LEFT);

    Label modeLabel = new Label("Mode:");
    hostButton = new RadioButton("Host");
    guestButton = new RadioButton("Guest");

    ToggleGroup toggleGroup = new ToggleGroup();
    hostButton.setToggleGroup(toggleGroup);
    guestButton.setToggleGroup(toggleGroup);

    HBox.setMargin(modeLabel, new Insets(0, 30, 0, 0));

    hBox.getChildren().addAll(modeLabel, hostButton, guestButton);
}
 
Example 20
Project: Maps   File: MapApp.java   View source code 6 votes vote down vote up
private LinkedList<RadioButton> setupToggle(ToggleGroup group) {

	  // Use Dijkstra as default
	  RadioButton rbD = new RadioButton("Dijkstra");
	  rbD.setUserData("Dijkstra");
	  rbD.setSelected(true);

	  RadioButton rbA = new RadioButton("A*");
	  rbA.setUserData("A*");

	  RadioButton rbB = new RadioButton("BFS");
	  rbB.setUserData("BFS");

	  rbB.setToggleGroup(group);
	  rbD.setToggleGroup(group);
	  rbA.setToggleGroup(group);
	  return new LinkedList<RadioButton>(Arrays.asList(rbB, rbD, rbA));
	}
 
Example 21
Project: aptasuite   File: SequencingDataCycleController.java   View source code 6 votes vote down vote up
/**
 * Loads the cycle specific information into the view
 */
public void setContent(SelectionCycle cycle, RadioButton countRadioButton, RadioButton percentageRadioButton, RadioButton linearRadioButton, RadioButton logarithmicRadioButton, ComboBox<Integer> randomizedRegionSizeComboBox) {
	
	this.cycle = cycle;
	this.countRadioButton = countRadioButton;
	this.percentageRadioButton = percentageRadioButton;
	this.randomizedRegionSizeComboBox = randomizedRegionSizeComboBox;
	this.linearRadioButton = linearRadioButton;
	this.logarithmicRadioButton = logarithmicRadioButton;
	
	// Update cycle info
	updateCycleInformation();
	
	// Update the charts
	updateForwardReadNucleotideDistribution();
	updateReverseReadNucleotideDistribution();
	updateRandomizedRegionFrequencyCharts();
	updateRandomizedRegionSizeDistribution();
	
}
 
Example 22
Project: NoticEditor   File: WebImportController.java   View source code 6 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
    importer = new WebImporter();
    importMode = HtmlImportMode.ORIGINAL;

    ObservableList<Node> nodes = modesBox.getChildren();
    nodes.clear();
    final ToggleGroup modesGroup = new ToggleGroup();
    for (HtmlImportMode value : HtmlImportMode.values()) {
        RadioButton radio = new RadioButton(resources.getString(value.getName()));
        if (value == importMode)
            radio.setSelected(true);
        radio.setOnAction(e -> onModeChanged(value));
        radio.setToggleGroup(modesGroup);
        nodes.add(radio);
    }

    pagePreview.getEngine().loadContent(resources.getString("preview"), "text/html");
}
 
Example 23
Project: FXGL   File: InterpolatorSample.java   View source code 6 votes vote down vote up
@Override
protected void initUI() {
    VBox vbox = new VBox(5);

    for (EasingInterpolator interpolator : Interpolators.values()) {
        Button btn = new Button(interpolator.toString());
        btn.disableProperty().bind(getGameState().booleanProperty("canPlay").not());
        btn.setOnAction(e -> playAnimation(interpolator));

        vbox.getChildren().add(btn);
    }

    RadioButton btn1 = new RadioButton("Ease In");
    RadioButton btn2 = new RadioButton("Ease Out");
    RadioButton btn3 = new RadioButton("Ease In Out");
    btn1.setToggleGroup(group);
    btn2.setToggleGroup(group);
    btn3.setToggleGroup(group);
    btn2.setSelected(true);

    vbox.getChildren().addAll(btn1, btn2, btn3);

    vbox.setTranslateX(650);
    getGameScene().addUINode(vbox);
}
 
Example 24
Project: dm3270   File: TransfersTab.java   View source code 6 votes vote down vote up
@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 ();
}
 
Example 25
Project: subshare   File: CertifyPgpKeyPane.java   View source code 6 votes vote down vote up
private void initSkipRadioButton() {
	// Move all children down, first.
	for (Node child : getChildren()) {
		final Integer rowIndex = getRowIndex(child);
		assertNotNull(rowIndex, "rowIndex[" + child + "]");
		setRowIndex(child, rowIndex + 1);
	}

	// Then add the skipRadioButton as top-most child.
	skipRadioButton = new RadioButton();
	skipRadioButton.setText("Do NOT certify this key, now. Skip signing it!");
	skipRadioButton.setToggleGroup(toggleGroup);
	setMargin(skipRadioButton, new Insets(0, 0, 8, 0));
	add(skipRadioButton, 0, 0, 2, 1);

	skipRadioButton.selectedProperty().bindBidirectional(certifyPgpKeyData.skipProperty());
}
 
Example 26
Project: UCSDGraphs   File: MapApp.java   View source code 6 votes vote down vote up
private LinkedList<RadioButton> setupToggle(ToggleGroup group) {

		// Use Dijkstra as default
		RadioButton rbD = new RadioButton("Dijkstra");
		rbD.setUserData("Dijkstra");
		rbD.setSelected(true);

		RadioButton rbA = new RadioButton("A*");
		rbA.setUserData("A*");

		RadioButton rbB = new RadioButton("BFS");
		rbB.setUserData("BFS");

		rbB.setToggleGroup(group);
		rbD.setToggleGroup(group);
		rbA.setToggleGroup(group);
		return new LinkedList<RadioButton>(Arrays.asList(rbB, rbD, rbA));
	}
 
Example 27
Project: Stud.IP-FileSync   File: StructureSettingsController.java   View source code 6 votes vote down vote up
@FXML
public void handleSave() {
	final RadioButton selected = (RadioButton) structureGroup.getSelectedToggle();

	try {
		if (option1.equals(selected)) {
			CONFIG.setFolderStructure(":semester/:lecture/:type");
			structureField.setText(":semester/:lecture/:type");
		} else if (option2.equals(selected)) {
			CONFIG.setFolderStructure(":semester/:course");
			structureField.setText(":semester/:course");
		} else if (option3.equals(selected)) {
			CONFIG.setFolderStructure(":lecture/:sem/:type");
			structureField.setText(":lecture/:sem/:type");
		} else {
			// FIXME Validate input.
			CONFIG.setFolderStructure(structureField.getText());
		}

	} catch (IOException e) {
		SimpleAlert.exception(e);
	}
}
 
Example 28
Project: mq-visualizer   File: MessageTypeDialog.java   View source code 6 votes vote down vote up
public MessageTypeDialog() {
    super(null, "Choose message type", false, DialogStyle.NATIVE);
    setMasthead("Choose message type");

    group = new ToggleGroup();

    RadioButton textButton = new RadioButton("Text");
    textButton.setUserData(new JmsTextMessage());
    textButton.setToggleGroup(group);
    textButton.setSelected(true);
    RadioButton bytesButton = new RadioButton("Bytes");
    bytesButton.setUserData(new JmsBytesMessage());
    bytesButton.setToggleGroup(group);

    HBox hbox = new HBox(5);
    hbox.getChildren().add(textButton);
    hbox.getChildren().add(bytesButton);
    setContent(hbox);

    Action action = new JmsMessageAction();
    action.disabledProperty().bind(group.selectedToggleProperty().isNull());

    ButtonBar.setType(action, ButtonBar.ButtonType.OK_DONE);
    getActions().addAll(action, Dialog.Actions.CANCEL);
}
 
Example 29
Project: FrameViewer-AnTracks   File: RadioButtonGroup.java   View source code 6 votes vote down vote up
public RadioButtonGroup(T[] values) {
// Call default constructor
this();

final Insets PADDING = new Insets(2);

// Create a radio button for each selectedValue
int i = 0;
for (T value : values) {
    RadioButton button = new RadioButton(value.toString());
    button.setToggleGroup(group);
    button.setAlignment(Pos.CENTER_LEFT);
    // Add the button to the grid layout
    add(button, 0, i);
    GridPane.setMargin(button, PADDING);

    valueToButton.put(value, button);

    i++;
}
   }
 
Example 30
Project: kotlinfx-ensemble   File: NodePropertiesSample.java   View source code 6 votes vote down vote up
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;
}
 
Example 31
Project: kotlinfx-ensemble   File: RadioButtons.java   View source code 6 votes vote down vote up
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);
}
 
Example 32
Project: pdfsam   File: PreferenceOutputPane.java   View source code 6 votes vote down vote up
@Inject
public PreferenceOutputPane(@Named("smartRadio") PreferenceRadioButton smartRadio) {
    I18nContext i18n = DefaultI18nContext.getInstance();
    ToggleGroup group = new ToggleGroup();

    RadioButton manualRadio = new RadioButton(i18n.i18n("Manually selected"));
    manualRadio.setToggleGroup(group);
    manualRadio.getStyleClass().addAll(Style.VITEM.css());
    manualRadio.setId("manualRadio");

    smartRadio.getStyleClass().addAll(Style.VITEM.css());
    smartRadio.setToggleGroup(group);
    smartRadio.setGraphic(helpIcon(DefaultI18nContext.getInstance()
            .i18n("Automatically set the destination directory to the selected PDF document directory")));
    smartRadio.getStyleClass().addAll(Style.WITH_HELP.css());

    if (isNull(group.getSelectedToggle())) {
        group.selectToggle(manualRadio);
    }

    getChildren().addAll(manualRadio, smartRadio);
    getStyleClass().addAll(Style.CONTAINER.css());
}
 
Example 33
Project: pdfsam   File: RadioButtonDrivenTextFieldsPane.java   View source code 6 votes vote down vote up
public void addRow(RadioButton radio, Region field, Text helpIcon) {
    requireNotNull(radio, "Cannot add a null radio");
    requireNotNull(field, "Cannot add a null field");
    GridPane.setValignment(radio, VPos.BOTTOM);
    GridPane.setValignment(field, VPos.BOTTOM);
    GridPane.setHalignment(radio, HPos.LEFT);
    GridPane.setHalignment(field, HPos.LEFT);
    GridPane.setFillWidth(field, true);
    field.setPrefWidth(300);
    field.setDisable(true);
    radio.selectedProperty().addListener((o, oldVal, newVal) -> {
        field.setDisable(!newVal);
        if (newVal) {
            field.requestFocus();
        }
    });
    radio.setToggleGroup(group);
    add(radio, 0, rows);
    add(field, 1, rows);
    if (nonNull(helpIcon)) {
        add(helpIcon, 2, rows);
    }
    rows++;

}
 
Example 34
Project: marathonv5   File: JavaFXToggleButtonElementTest.java   View source code 5 votes vote down vote up
@Test public void selectRadioBottonSelectedSelected() {
    RadioButton radioButtonNode = (RadioButton) getPrimaryStage().getScene().getRoot().lookup(".radio-button");
    radioButtonNode.setSelected(true);
    AssertJUnit.assertEquals(true, radioButtonNode.isSelected());
    radioButton.marathon_select("true");
    new Wait("Waiting for the radio button selection.") {
        @Override public boolean until() {
            return radioButtonNode.isSelected();
        }
    };
}
 
Example 35
Project: marathonv5   File: JavaFXToggleButtonElementTest.java   View source code 5 votes vote down vote up
@Test public void selectRadiobuttonSelectedNotSelected() {
    Set<Node> radioButtonNodes = getPrimaryStage().getScene().getRoot().lookupAll(".radio-button");
    List<Node> nodes = new ArrayList<>(radioButtonNodes);
    RadioButton radioButtonNode = (RadioButton) nodes.get(1);
    AssertJUnit.assertEquals(true, radioButtonNode.isSelected());
    radioButton.marathon_select("false");
    new Wait("Waiting for the radio button deselect.") {
        @Override public boolean until() {
            return radioButtonNode.isSelected();
        }
    };
}
 
Example 36
Project: marathonv5   File: JavaFXToggleButtonElementTest.java   View source code 5 votes vote down vote up
@Test public void selectRadiobuttonNotSelectedSelected() {
    RadioButton radioButtonNode = (RadioButton) getPrimaryStage().getScene().getRoot().lookup(".radio-button");
    AssertJUnit.assertEquals(false, radioButtonNode.isSelected());
    radioButton.marathon_select("true");
    new Wait("Waiting for the radio button selection.") {
        @Override public boolean until() {
            return radioButtonNode.isSelected();
        }
    };
}
 
Example 37
Project: marathonv5   File: JavaFXToggleButtonElementTest.java   View source code 5 votes vote down vote up
@Test public void selectRadiobuttoNotSelectedNotSelected() {
    RadioButton radioButtonNode = (RadioButton) getPrimaryStage().getScene().getRoot().lookup(".radio-button");
    AssertJUnit.assertEquals(false, radioButtonNode.isSelected());
    radioButton.marathon_select("false");
    new Wait("Waiting for the radio button state.") {
        @Override public boolean until() {
            return !radioButtonNode.isSelected();
        }
    };
}
 
Example 38
Project: marathonv5   File: JavaFXToggleButtonElementTest.java   View source code 5 votes vote down vote up
@Test public void getText() {
    RadioButton radioButtonNode = (RadioButton) getPrimaryStage().getScene().getRoot().lookup(".radio-button");
    AssertJUnit.assertEquals(false, radioButtonNode.isSelected());
    List<String> text = new ArrayList<>();
    Platform.runLater(() -> {
        radioButton.marathon_select("true");
        text.add(radioButton.getAttribute("text"));
    });
    new Wait("Waiting for the toggle button text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Hello", text.get(0));
}
 
Example 39
Project: marathonv5   File: RFXToggleButtonTest.java   View source code 5 votes vote down vote up
@Test public void selectRadioButtonSelected() {
    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(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]);
}
 
Example 40
Project: Kramer   File: AutoLayoutController.java   View source code 5 votes vote down vote up
public AutoLayoutController(QueryState queryState) throws IOException {
    initialize();
    this.activeQuery.initializeFrom(queryState);
    this.queryState = queryState;
    load();
    Node graphiql = constructGraphiql();
    anchor.getChildren()
          .add(graphiql);
    showQuery.setSelected(true);
    page.selectedToggleProperty()
        .addListener((o, p, c) -> {
            try {
                RadioButton prev = (RadioButton) p;
                RadioButton current = (RadioButton) c;

                if (prev == showSchema) {
                    layout.autoLayout();
                }

                if (current == showLayout) {
                    anchor.getChildren()
                          .setAll(layout);
                } else if (current == showSchema) {
                    anchor.getChildren()
                          .setAll(schemaView);
                } else if (current == showQuery) {
                    anchor.getChildren()
                          .setAll(graphiql);
                } else {
                    throw new IllegalStateException(String.format("Invalid radio button: %s",
                                                                  current));
                }
            } catch (Exception e) {
                log.error("exception processing toggle", e);
            }
        });
}