Example usage for javafx.scene.control RadioButton setSelected

List of usage examples for javafx.scene.control RadioButton setSelected

Introduction

In this page you can find the example usage for javafx.scene.control RadioButton setSelected.

Prototype

public final void setSelected(boolean value) 

Source Link

Usage

From source file:Main.java

private static RadioButton createRadioButton(final String text, final ToggleGroup toggleGroup,
        final boolean selected) {
    final RadioButton radioButton = new RadioButton(text);
    radioButton.setToggleGroup(toggleGroup);
    radioButton.setSelected(selected);

    return radioButton;
}

From source file:Main.java

@Override
public void start(Stage stage) {
    HBox root = new HBox();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);/*from   w w w .  j  a va 2  s . co m*/
    stage.setTitle("");

    ToggleGroup group = new ToggleGroup();
    RadioButton button1 = new RadioButton("select first");
    button1.setToggleGroup(group);
    button1.setSelected(true);
    RadioButton button2 = new RadioButton("select second");
    button2.setToggleGroup(group);

    root.getChildren().add(button1);
    root.getChildren().add(button2);

    scene.setRoot(root);
    stage.show();
}

From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java

private RadioButton createRadioButtonForType(final Type aType, final String title,
        final ToggleGroup toggleGroup) {
    final RadioButton result = new RadioButton(title);
    result.setToggleGroup(toggleGroup);/*from w  w w.  j ava2s.com*/
    result.setSelected(this.type == aType);
    result.setOnAction(event -> {
        this.setType(aType);
        this.getGraph().handleChange();
    });
    return result;
}

From source file:fruitproject.FruitProject.java

public void first(final Stage primaryStage) {
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);/*from  ww w. j ava  2s.c o  m*/
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    rows = 0;
    addPairs.clear();

    Text lb = new Text();
    lb.setText("J-Fruit");
    //lb.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(lb, 1, 0);

    final ToggleGroup grp = new ToggleGroup();
    RadioButton rb1 = new RadioButton();
    rb1.setText("Add Fruit file");
    rb1.setUserData("add");
    rb1.setToggleGroup(grp);
    rb1.setSelected(true);
    grid.add(rb1, 1, 1);

    RadioButton rb2 = new RadioButton();
    rb2.setText("Load Fruit file");
    rb2.setUserData("load");
    rb2.setToggleGroup(grp);
    grid.add(rb2, 1, 2);

    Label label1 = new Label("Enter File Name:");
    final TextField tfFilename = new TextField();
    final HBox hb = new HBox();
    hb.getChildren().addAll(label1, tfFilename);
    hb.setSpacing(10);
    hb.setVisible(false);
    tfFilename.setText("");
    grid.add(hb, 1, 3);

    grp.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
            if (grp.getSelectedToggle() != null) {
                // System.out.println(grp.getSelectedToggle().getUserData().toString());
                if (grp.getSelectedToggle().getUserData().toString() == "load")
                    hb.setVisible(true);
                else {
                    hb.setVisible(false);
                    tfFilename.setText("");
                }
            }
        }
    });

    if (rb2.isSelected() == true) {
        hb.setVisible(true);
    }

    Button btn = new Button();
    btn.setText("GO");
    grid.add(btn, 1, 4);
    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            //System.out.println("Hello World!");
            if (tfFilename.getText() == "")
                second("");
            else
                second(tfFilename.getText());
            primaryStage.close();
        }
    });

    //StackPane root = new StackPane();
    //root.getChildren().add(lb);
    //root.getChildren().add(rb1);
    //root.getChildren().add(rb2);
    //root.getChildren().add(btn);

    Scene scene = new Scene(grid, 400, 450);
    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();

}

From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java

public void createLogFileSourceInputItems(final List<Triple<String, Node, String>> formItems) {
    final TextField logFilePath = new TextField();
    this.logFilePathProperty.bind(logFilePath.textProperty());
    HBox.setHgrow(logFilePath, Priority.ALWAYS);
    final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(logFilePath,
            LogReaderEditor.LOG_FILE_ICON_NAME, "Select log file", null, null);
    final HBox fileInputConfig = new HBox(logFilePath, selectLogFileButton);
    final VBox lines = new VBox();
    final double spacingOfLines = 5d;
    lines.setSpacing(spacingOfLines);/*from ww  w  .  j a va2s  .c o m*/
    final HBox inputTypeLine = new HBox();
    final double hSpacingOfInputTypeChoices = 30d;
    inputTypeLine.setSpacing(hSpacingOfInputTypeChoices);
    final ToggleGroup group = new ToggleGroup();
    final RadioButton inputTypeText = new RadioButton("Paste/Enter log");
    inputTypeText.setToggleGroup(group);
    this.loadLogFromEnteredTextProperty.bind(inputTypeText.selectedProperty());
    final RadioButton inputTypeFile = new RadioButton("Read log file");
    inputTypeFile.setToggleGroup(group);
    this.loadLogFromFileProperty.bind(inputTypeFile.selectedProperty());
    inputTypeFile.setSelected(true);
    inputTypeLine.getChildren().add(inputTypeText);
    inputTypeLine.getChildren().add(inputTypeFile);
    fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty());
    fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty());
    final TextArea logInputText = new TextArea();
    HBox.setHgrow(logInputText, Priority.ALWAYS);
    final int numLinesForEnteringLogInputManually = 10;
    logInputText.setPrefRowCount(numLinesForEnteringLogInputManually);
    logInputText.setStyle("-fx-font-family: monospace");
    this.enteredLogTextProperty.bind(logInputText.textProperty());
    final HBox enterTextConfig = new HBox();
    enterTextConfig.getChildren().add(logInputText);
    enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty());
    enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty());
    lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig);
    formItems.add(Triple.of("Trace Log", lines, null));
}

From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java

private Node createRadioButtonInput(final ToggleGroup tg, final String propertyName,
        final boolean isInitiallySelected, final Consumer<Boolean> applyValue) {
    final RadioButton result = new RadioButton(propertyName);
    result.setToggleGroup(tg);/*www .j  ava 2  s  .co m*/
    result.setSelected(isInitiallySelected);
    result.setOnAction(event -> {
        applyValue.accept(result.isSelected());
        this.getGraph().handleChange();
    });
    return result;
}

From source file:boundary.GraphPane.java

private HBox addTransformingModeOptions() {
    HBox hBox = new HBox();

    hBox.setPadding(new Insets(15, 12, 15, 12));
    hBox.setSpacing(10);/*  w ww.j a va  2  s.  c  o  m*/
    hBox.setStyle("-fx-background-color: #66FFFF;");

    final ToggleGroup optionGroup = new ToggleGroup();

    Label lblMouseMode = new Label("Mouse Mode: ");
    lblMouseMode.setPrefSize(100, 20);

    RadioButton rbTransform = new RadioButton("Pan & Zoom");
    rbTransform.setPrefSize(100, 20);
    rbTransform.setToggleGroup(optionGroup);
    rbTransform.setUserData("T");
    rbTransform.setSelected(true);

    RadioButton rbPick = new RadioButton("Picking");
    rbPick.setPrefSize(100, 20);
    rbPick.setUserData("P");
    rbPick.setToggleGroup(optionGroup);

    optionGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {

        @Override
        public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
            if (optionGroup.getSelectedToggle() != null) {
                DefaultModalGraphMouse dmg = (DefaultModalGraphMouse) vv.getGraphMouse();

                if (optionGroup.getSelectedToggle().getUserData().equals("T")) {
                    dmg.setMode(Mode.TRANSFORMING);
                } else if (optionGroup.getSelectedToggle().getUserData().equals("P")) {
                    dmg.setMode(Mode.PICKING);
                }
            }

        }
    });

    hBox.getChildren().addAll(lblMouseMode, rbTransform, rbPick);

    return hBox;

}

From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignView.java

public void addConfigFile(String text, String description, boolean selected) {
    RadioButton radio = new RadioButton();
    radio.setId("radioConfig" + vBoxConfig.getChildren().size());
    radio.setText(text);//from  w ww  . j  a v a2  s  .c o  m
    radio.setToggleGroup(group);
    radio.setSelected(selected);
    if (description != null && !description.isEmpty()) {
        radio.setTooltip(new Tooltip(description));
    }
    radio.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            selectedButton = radio;
        }
    });
    vBoxConfig.getChildren().add(radio);
    if (selected) {
        selectedButton = radio;
    }
}

From source file:FeeBooster.java

private GridPane rbfGrid(Transaction tx) {
    // Setup grid
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);/*www  .ja v a2  s  . c om*/
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));
    int inGridHeight = 0;
    int outGridHeight = 0;

    // Add inputs to table
    Label inputHdrLbl = new Label("Inputs");
    grid.add(inputHdrLbl, 0, inGridHeight);
    inGridHeight++;
    for (int i = 0; i < tx.getInputs().size(); i++) {
        // Add input to table
        TxInput in = tx.getInputs().get(i);
        Text inputTxt = new Text("Txid: " + in.getTxid() + "\nIndex: " + in.getVout());
        grid.add(inputTxt, 0, inGridHeight);
        inGridHeight++;
    }

    // Add outputs to table
    Label outputHdrLbl = new Label("Outputs");
    grid.add(outputHdrLbl, 1, outGridHeight);
    outGridHeight++;
    ToggleGroup outputGroup = new ToggleGroup();
    for (int i = 0; i < tx.getOutputs().size(); i++) {
        // Add output to table
        TxOutput out = tx.getOutputs().get(i);
        Text outputTxt = new Text("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress());
        outputTxt.setUserData(i);
        grid.add(outputTxt, 1, outGridHeight);

        // Add radio button to table
        RadioButton radio = new RadioButton();
        radio.setUserData(i);
        radio.setToggleGroup(outputGroup);
        radio.setSelected(true);
        grid.add(radio, 2, outGridHeight);
        outGridHeight++;
    }

    // Set gridheight
    int gridheight = (inGridHeight < outGridHeight) ? outGridHeight : inGridHeight;
    gridheight++;

    // Fee
    Text fee = new Text("Fee Paid: " + tx.getFee() + " Satoshis");
    grid.add(fee, 0, gridheight);

    // Recommended fee from bitcoinfees.21.co
    JSONObject apiResult = Utils.getFromAnAPI("http://bitcoinfees.21.co/api/v1/fees/recommended", "GET");
    int fastestFee = apiResult.getInt("fastestFee");
    long recommendedFee = fastestFee * tx.getSize();
    Text recFeeTxt = new Text("Recommended Fee: " + recommendedFee + " Satoshis");
    grid.add(recFeeTxt, 1, gridheight);
    gridheight += 2;

    // Instructions
    Text instructions = new Text(
            "Choose an output to deduct an additional fee from. Then increase the fee below.");
    grid.add(instructions, 0, gridheight, 3, 1);
    gridheight++;

    // Fee spinner
    Spinner feeSpin = new Spinner((double) tx.getFee(), (double) tx.getTotalAmt(), (double) tx.getFee());
    feeSpin.setEditable(true);
    grid.add(feeSpin, 0, gridheight);
    feeSpin.valueProperty().addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            double oldVal = (double) oldValue;
            double newVal = (double) newValue;
            Double step = newVal - oldVal;
            tx.setFee(tx.getFee() + step.longValue());
            fee.setText("Fee Paid: " + tx.getFee() + " Satoshis");
            int output = (int) outputGroup.getSelectedToggle().getUserData();
            TxOutput out = tx.getOutputs().get(output);
            out.decreaseValueBy(step.longValue());
            for (int i = 0; i < grid.getChildren().size(); i++) {
                Node child = grid.getChildren().get(i);
                if (grid.getRowIndex(child) == output + 1 && grid.getColumnIndex(child) == 1) {
                    ((Text) child)
                            .setText("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress());
                }
            }
        }
    });

    // Set to recommended fee button
    Button recFeeBtn = new Button("Set fee to recommended");
    grid.add(recFeeBtn, 1, gridheight);
    gridheight++;
    recFeeBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            long prevFee = tx.getFee();
            long step = recommendedFee - prevFee;
            feeSpin.increment((int) step);
        }
    });

    // Next Button
    Button nextBtn = new Button("Next");
    grid.add(nextBtn, 1, gridheight);
    nextBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            if (sceneCursor == scenes.size() - 1) {
                Scene scene = new Scene(unsignedTxGrid(tx), 900, 500);
                scenes.add(scene);
                sceneCursor++;
                stage.setScene(scene);
            } else {
                sceneCursor++;
                stage.setScene(scenes.get(sceneCursor));
            }
        }
    });
    HBox btnHbox = new HBox(10);

    // Back Button
    Button backBtn = new Button("Back");
    backBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            sceneCursor--;
            stage.setScene(scenes.get(sceneCursor));
        }
    });
    btnHbox.getChildren().add(backBtn);
    btnHbox.getChildren().add(nextBtn);

    // Cancel Button
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setOnAction(cancelEvent);
    btnHbox.getChildren().add(cancelBtn);
    grid.add(btnHbox, 1, gridheight);

    return grid;
}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

public VBox createRunForm() {
    // CHECKSTYLE:OFF Yes, we are using lots of constants here. It does not make sense to name them using final variables.
    final VBox lines = new VBox();
    lines.setSpacing(10d);//from  ww  w  . j a  v a  2s. co  m
    final HBox inputTypeLine = new HBox();
    inputTypeLine.setSpacing(30d);
    final ToggleGroup group = new ToggleGroup();
    final RadioButton inputTypeText = new RadioButton("Paste/Enter text");
    inputTypeText.setToggleGroup(group);
    final RadioButton inputTypeFile = new RadioButton("Read log file");
    inputTypeFile.setToggleGroup(group);
    inputTypeLine.getChildren().add(inputTypeText);
    inputTypeLine.getChildren().add(inputTypeFile);
    inputTypeText.setSelected(true);
    final TextField pathInput = new TextField();
    HBox.setHgrow(pathInput, Priority.ALWAYS);
    final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(pathInput,
            LOG_FILE_ICON_NAME, "Select log file", null, null);
    final Text pathInputLabel = new Text("Log file path: ");
    final HBox fileInputConfig = new HBox();
    fileInputConfig.setAlignment(Pos.CENTER_LEFT);
    fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty());
    fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty());
    fileInputConfig.getChildren().addAll(pathInputLabel, pathInput, selectLogFileButton);
    final TextArea logInputText = new TextArea();
    HBox.setHgrow(logInputText, Priority.ALWAYS);
    logInputText.setPrefRowCount(10);
    logInputText.setStyle("-fx-font-family: monospace");
    final HBox enterTextConfig = new HBox();
    enterTextConfig.getChildren().add(logInputText);
    enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty());
    enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty());
    final Button startBtn = new Button("Read Log");
    startBtn.setPadding(new Insets(8d));
    // CHECKSTYLE:ON
    startBtn.setGraphic(Icons.getIconGraphics("control_play_blue"));
    HBox.setHgrow(startBtn, Priority.ALWAYS);
    startBtn.setMaxWidth(Double.MAX_VALUE);
    startBtn.setOnAction(event -> this.runLogFileReader(inputTypeFile, pathInput, logInputText));
    final HBox startLine = new HBox();
    startLine.getChildren().add(startBtn);
    lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig, startLine, new Text("Results:"),
            this.parsedLogEntries);
    return lines;
}