Search in sources :

Example 26 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project selenium_java by sergueik.

the class ComplexFormEx method start.

@SuppressWarnings("restriction")
@Override
public void start(Stage stage) {
    BorderPane root = new BorderPane();
    stage.setTitle(inputData.containsKey("title") ? inputData.get("title") : "Element Locators");
    Scene scene = new Scene(root, 480, 250, Color.WHITE);
    // stage.setScene(new Scene(root, 480, 250, Color.WHITE));
    stage.setScene(scene);
    GridPane gridPane1 = new GridPane();
    GridPane gridPane = new GridPane();
    gridPane.setRowIndex(gridPane, 0);
    gridPane.setColumnIndex(gridPane, 0);
    HBox buttonbarHbox = new HBox(10);
    buttonbarHbox.setPadding(new Insets(10));
    // buttonbarHbox.setSpacing(50);
    // buttonbarHbox.setPadding(new Insets(10, 10, 10, 10));
    // gridPane.setVgap(5);
    gridPane.setRowIndex(buttonbarHbox, 1);
    gridPane.setColumnIndex(buttonbarHbox, 0);
    // Save button
    Button saveButton = new Button("Save");
    saveButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Saved");
            Stage stage = (Stage) ((Button) (event.getSource())).getScene().getWindow();
            stage.close();
        }
    });
    saveButton.setDefaultButton(true);
    // Delete button
    Button deleteButton = new Button("Delete");
    deleteButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Deleted");
            Stage stage = (Stage) ((Button) (event.getSource())).getScene().getWindow();
            stage.close();
        }
    });
    // Cancel button
    Button cancelButton = new Button("Cancel");
    cancelButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Cancel");
            Stage stage = (Stage) ((Button) (event.getSource())).getScene().getWindow();
            stage.close();
        }
    });
    buttonbarHbox.getChildren().addAll(saveButton, deleteButton, cancelButton);
    gridPane.setPadding(new Insets(20, 10, 10, 20));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    gridPane.setStyle("-fx-padding: 10; -fx-border-style: solid inside; -fx-border-width: 2; -fx-border-insets: 5; -fx-border-radius: 0; -fx-border-color: darkgray;");
    ToggleGroup group = new ToggleGroup();
    // CSS
    RadioButton cssButton = new RadioButton("css");
    cssButton.setToggleGroup(group);
    cssButton.setSelected(true);
    gridPane.setHalignment(cssButton, HPos.LEFT);
    gridPane.add(cssButton, 0, 0);
    TextField cssFld = new TextField();
    gridPane.setHalignment(cssFld, HPos.LEFT);
    cssFld.setMaxWidth(Double.MAX_VALUE);
    gridPane.add(cssFld, 1, 0);
    // XPath
    RadioButton xpathButton = new RadioButton("xpath");
    xpathButton.setToggleGroup(group);
    gridPane.setHalignment(xpathButton, HPos.LEFT);
    gridPane.add(xpathButton, 0, 1);
    TextField xpathFld = new TextField();
    gridPane.setHalignment(xpathFld, HPos.LEFT);
    xpathFld.setMaxWidth(Double.MAX_VALUE);
    gridPane.add(xpathFld, 1, 1);
    // ID
    RadioButton idButton = new RadioButton("id");
    idButton.setToggleGroup(group);
    gridPane.setHalignment(idButton, HPos.LEFT);
    gridPane.add(idButton, 0, 2);
    idButton.setDisable(true);
    TextField idFld = new TextField();
    gridPane.setHalignment(idFld, HPos.LEFT);
    idFld.setMaxWidth(Double.MAX_VALUE);
    gridPane.add(idFld, 1, 2);
    idFld.setDisable(true);
    RadioButton textButton = new RadioButton("text");
    textButton.setToggleGroup(group);
    gridPane.setHalignment(textButton, HPos.LEFT);
    gridPane.add(textButton, 0, 3);
    TextField textFld = new TextField();
    gridPane.setHalignment(textFld, HPos.LEFT);
    textFld.setMaxWidth(Double.MAX_VALUE);
    gridPane.add(textFld, 1, 3);
    // constant
    final RowConstraints rowConstraints = new RowConstraints(64);
    // height
    final ColumnConstraints column1Constraints = new ColumnConstraints(100, Control.USE_COMPUTED_SIZE, Control.USE_COMPUTED_SIZE);
    final ColumnConstraints column2Constraints = new ColumnConstraints(250, Control.USE_COMPUTED_SIZE, Double.MAX_VALUE);
    gridPane.getRowConstraints().add(rowConstraints);
    column2Constraints.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(column1Constraints, column2Constraints);
    gridPane.prefWidthProperty().bind(root.widthProperty());
    gridPane1.getChildren().addAll(gridPane, buttonbarHbox);
    gridPane1.prefWidthProperty().bind(root.widthProperty());
    root.getChildren().add(gridPane1);
    scene.setRoot(root);
    stage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) HBox(javafx.scene.layout.HBox) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) ActionEvent(javafx.event.ActionEvent) ColumnConstraints(javafx.scene.layout.ColumnConstraints) RadioButton(javafx.scene.control.RadioButton) Scene(javafx.scene.Scene) RowConstraints(javafx.scene.layout.RowConstraints) Button(javafx.scene.control.Button) RadioButton(javafx.scene.control.RadioButton) ToggleGroup(javafx.scene.control.ToggleGroup) Stage(javafx.stage.Stage) TextField(javafx.scene.control.TextField)

Example 27 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project financial by greatkendy123.

the class MyController method initWhiteVersion.

/**
 * 初始化白名单版本
 *
 * @time 2018年1月4日
 */
private void initWhiteVersion() {
    ToggleGroup group = new ToggleGroup();
    whiteVersionOld.setToggleGroup(group);
    whiteVersionNew.setToggleGroup(group);
    // "旧名单"
    whiteVersionOld.setUserData(0);
    // "新名单"
    whiteVersionNew.setUserData(1);
    whiteVersionOld.setSelected(true);
    log.info("默认导入版本:新名单");
    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {

        public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) {
            Integer version = (Integer) group.getSelectedToggle().getUserData();
            if (version == 1) {
                log.info("导入版本:新名单");
            // ShowUtil.show("新名单版本未开发!!!");
            } else {
                log.info("导入版本:旧名单");
            }
        }
    });
}
Also used : ToggleGroup(javafx.scene.control.ToggleGroup) Toggle(javafx.scene.control.Toggle)

Example 28 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project financial by greatkendy123.

the class MyController method initAutoTestMode.

/**
 * 启动测试模式
 *
 * @time 2017年11月11日
 */
private void initAutoTestMode() {
    hbox_autoTestMode.setVisible(false);
    ToggleGroup group = new ToggleGroup();
    radio_autoTest_yes.setToggleGroup(group);
    radio_autoTest_no.setToggleGroup(group);
    radio_autoTest_yes.setUserData("是");
    radio_autoTest_no.setUserData("否");
    radio_autoTest_no.setSelected(true);
    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {

        public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) {
            String autoTestMode = (String) group.getSelectedToggle().getUserData();
            if ("是".equals(autoTestMode)) {
                hbox_autoTestMode.setVisible(true);
            } else {
                hbox_autoTestMode.setVisible(false);
            }
        }
    });
}
Also used : ToggleGroup(javafx.scene.control.ToggleGroup) Toggle(javafx.scene.control.Toggle)

Example 29 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project Smartcity-Smarthouse by TechnionYP5777.

the class SendMessageController method addBoolField.

private void addBoolField(String fieldName) {
    Label label = new Label(fieldName + ":");
    final ToggleGroup group = new ToggleGroup();
    RadioButton rb1 = new RadioButton("Random");
    rb1.setToggleGroup(group);
    rb1.setSelected(true);
    RadioButton rb2 = new RadioButton("True");
    rb2.setToggleGroup(group);
    RadioButton rb3 = new RadioButton("False");
    rb3.setToggleGroup(group);
    HBox hb = new HBox(label, rb1, rb2, rb3);
    hb.setSpacing(3);
    VBox vbox = new VBox(label, hb);
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    mainPane.getChildren().add(vbox);
    consumers.add(l -> {
        List<Boolean> input = new ArrayList<>();
        RadioButton selectedRadioButton = (RadioButton) group.getSelectedToggle();
        switch(selectedRadioButton.getText()) {
            case "Random":
                input.add(true);
                input.add(false);
                break;
            case "True":
                input.add(true);
                break;
            case "False":
                input.add(false);
                break;
        }
        l.put(fieldName, input);
    });
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) ToggleGroup(javafx.scene.control.ToggleGroup) Label(javafx.scene.control.Label) ArrayList(java.util.ArrayList) RadioButton(javafx.scene.control.RadioButton) VBox(javafx.scene.layout.VBox)

Example 30 with ToggleGroup

use of javafx.scene.control.ToggleGroup in project trex-stateless-gui by cisco-system-traffic-generator.

the class MultiplierOption method buildUI.

/**
 * Build multiplier view UI
 *
 * @param title
 * @param group
 */
private void buildUI(String title, ToggleGroup group) {
    // add radio button
    selection = new RadioButton(title);
    selection.setToggleGroup(group);
    selection.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
        if (newValue) {
            multiplierSelectionEvent.onMultiplierSelect(type);
        }
        value.setDisable(!newValue);
    });
    setTooltip();
    getChildren().add(selection);
    MultiplierOption.setTopAnchor(selection, 15d);
    MultiplierOption.setLeftAnchor(selection, 0d);
    // text field
    value = new TextField();
    value.setPrefSize(120, 22);
    value.setDisable(true);
    value.addEventFilter(KeyEvent.KEY_RELEASED, multiplierSelectionEvent.validateInput());
    String regex = unitRegex();
    final UnaryOperator<TextFormatter.Change> keyPressFilter = c -> {
        String text = c.getControlNewText();
        if (text.matches(regex)) {
            return c;
        } else {
            return null;
        }
    };
    value.setTextFormatter(new TextFormatter<>(keyPressFilter));
    getChildren().add(value);
    MultiplierOption.setTopAnchor(value, 43d);
    MultiplierOption.setLeftAnchor(value, 0d);
    MultiplierOption.setBottomAnchor(value, 15d);
}
Also used : TextField(javafx.scene.control.TextField) MultiplierType(com.exalttech.trex.ui.MultiplierType) Util(com.exalttech.trex.util.Util) UnaryOperator(java.util.function.UnaryOperator) KeyEvent(javafx.scene.input.KeyEvent) TextFormatter(javafx.scene.control.TextFormatter) Logger(org.apache.log4j.Logger) ToggleGroup(javafx.scene.control.ToggleGroup) AnchorPane(javafx.scene.layout.AnchorPane) RadioButton(javafx.scene.control.RadioButton) ObservableValue(javafx.beans.value.ObservableValue) MultiplierSelectionEvent(com.exalttech.trex.ui.components.events.MultiplierSelectionEvent) Tooltip(javafx.scene.control.Tooltip) ObservableValue(javafx.beans.value.ObservableValue) TextField(javafx.scene.control.TextField) RadioButton(javafx.scene.control.RadioButton)

Aggregations

ToggleGroup (javafx.scene.control.ToggleGroup)32 Insets (javafx.geometry.Insets)10 RadioButton (javafx.scene.control.RadioButton)9 HBox (javafx.scene.layout.HBox)9 ToggleButton (javafx.scene.control.ToggleButton)8 Label (javafx.scene.control.Label)7 VBox (javafx.scene.layout.VBox)6 Toggle (javafx.scene.control.Toggle)5 Button (javafx.scene.control.Button)4 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)3 Scene (javafx.scene.Scene)3 AutoTooltipRadioButton (bisq.desktop.components.AutoTooltipRadioButton)2 BsqReceiveView (bisq.desktop.main.dao.wallet.receive.BsqReceiveView)2 Popup (bisq.desktop.main.overlays.popups.Popup)2 List (java.util.List)2 FXCollections (javafx.collections.FXCollections)2 Node (javafx.scene.Node)2 CheckBox (javafx.scene.control.CheckBox)2 ComboBox (javafx.scene.control.ComboBox)2 MenuItem (javafx.scene.control.MenuItem)2