Search in sources :

Example 1 with RadioButton

use of javafx.scene.control.RadioButton in project JFoenix by jfoenixadmin.

the class JFXRadioButtonSkin method layoutChildren.

@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
    final RadioButton radioButton = getSkinnable();
    contWidth = snapSize(container.prefWidth(-1)) + (invalid ? 2 : 0);
    contHeight = snapSize(container.prefHeight(-1)) + (invalid ? 2 : 0);
    final double computeWidth = Math.min(radioButton.prefWidth(-1), radioButton.minWidth(-1)) + labelOffset + 2 * padding;
    final double labelWidth = Math.min(computeWidth - contWidth, w - snapSize(contWidth)) + labelOffset + 2 * padding;
    final double labelHeight = Math.min(radioButton.prefHeight(labelWidth), h);
    maxHeight = Math.max(contHeight, labelHeight);
    final double xOffset = computeXOffset(w, labelWidth + contWidth, radioButton.getAlignment().getHpos()) + x;
    final double yOffset = computeYOffset(h, maxHeight, radioButton.getAlignment().getVpos()) + x;
    if (invalid) {
        initializeComponents(x, y, w, h);
        invalid = false;
    }
    layoutLabelInArea(xOffset + contWidth, yOffset, labelWidth, maxHeight, radioButton.getAlignment());
    ((Text) getChildren().get((getChildren().get(0) instanceof Text) ? 0 : 1)).textProperty().set(getSkinnable().textProperty().get());
    container.resize(snapSize(contWidth), snapSize(contHeight));
    positionInArea(container, xOffset, yOffset, contWidth, maxHeight, 0, radioButton.getAlignment().getHpos(), radioButton.getAlignment().getVpos());
}
Also used : Text(javafx.scene.text.Text) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) RadioButton(javafx.scene.control.RadioButton)

Example 2 with RadioButton

use of javafx.scene.control.RadioButton in project SmartCity-Market by TechnionYP5777.

the class ManageCatalogProductTab method initialize.

@Override
public void initialize(URL location, ResourceBundle __) {
    barcodeEventHandler.register(this);
    barcodeTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("\\d*"))
            barcodeTextField.setText(newValue.replaceAll("[^\\d]", ""));
        enableRunOperation();
    });
    productNameTextField.textProperty().addListener((observable, oldValue, newValue) -> enableRunOperation());
    productDescriptionTextField.textProperty().addListener((observable, oldValue, newValue) -> enableRunOperation());
    createManufacturerMap();
    productManufacturerCombo.getItems().addAll(manufacturars.keySet());
    productManufacturerCombo.valueProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(@SuppressWarnings("rawtypes") ObservableValue __, String s, String t1) {
            enableRunOperation();
        }
    });
    productPriceTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("((\\d*)|(\\d+\\.\\d*))"))
            productPriceTextField.setText(oldValue);
        enableRunOperation();
    });
    createIngredientMap();
    ingridientsCombo.getItems().addAll(ingredients.keySet());
    // productLocationTextField.textProperty().addListener((observable,
    // oldValue, newValue) -> {
    // });
    radioButtonContainerManageCatalogProduct.addRadioButtons(Arrays.asList(new RadioButton[] { addCatalogProductRadioButton, removeCatalogProductRadioButton }));
    RequiredFieldValidator validator = new RequiredFieldValidator();
    validator.setMessage("Input Required");
    validator.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    barcodeTextField.getValidators().add(validator);
    barcodeTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            barcodeTextField.validate();
    });
    RequiredFieldValidator validator2 = new RequiredFieldValidator();
    validator2.setMessage("Input Required");
    validator2.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    productNameTextField.getValidators().add(validator2);
    productNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            productNameTextField.validate();
    });
    RequiredFieldValidator validator3 = new RequiredFieldValidator();
    validator3.setMessage("Input Required");
    validator3.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    productPriceTextField.getValidators().add(validator3);
    productPriceTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            productPriceTextField.validate();
    });
    enableRunOperation();
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) RadioButton(javafx.scene.control.RadioButton) FontAwesomeIconView(de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator)

Example 3 with RadioButton

use of javafx.scene.control.RadioButton in project SmartCity-Market by TechnionYP5777.

the class ManageEmployeesTab method initialize.

@Override
public void initialize(URL location, ResourceBundle __) {
    userTxt.textProperty().addListener((observable, oldValue, newValue) -> enableFinishBtn());
    passTxt.textProperty().addListener((observable, oldValue, newValue) -> enableFinishBtn());
    securityAnswerTxt.textProperty().addListener((observable, oldValue, newValue) -> enableFinishBtn());
    radioBtnCont.addRadioButtons(Arrays.asList(new RadioButton[] { workerRadioBtn, managerRadioBtn }));
    securityCombo.getItems().addAll(SecurityQuestions.getQuestions());
    RequiredFieldValidator validator2 = new RequiredFieldValidator();
    validator2.setMessage("Input Required");
    validator2.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    userTxt.getValidators().add(validator2);
    userTxt.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            userTxt.validate();
    });
    RequiredFieldValidator validator3 = new RequiredFieldValidator();
    validator3.setMessage("Input Required");
    validator3.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    passTxt.getValidators().add(validator3);
    passTxt.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            passTxt.validate();
    });
    RequiredFieldValidator validator4 = new RequiredFieldValidator();
    validator4.setMessage("Input Required");
    validator4.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    securityAnswerTxt.getValidators().add(validator4);
    securityAnswerTxt.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            securityAnswerTxt.validate();
    });
    createEmployeesList();
    searchEmployee.textProperty().addListener(obs -> {
        String filter = searchEmployee.getText();
        filteredDataEmployees.setPredicate(filter == null || filter.length() == 0 ? s -> true : s -> s.contains(filter));
    });
    employeesList.setCellFactory(CheckBoxListCell.forListView(new Callback<String, ObservableValue<Boolean>>() {

        @Override
        public ObservableValue<Boolean> call(String item) {
            BooleanProperty observable = new SimpleBooleanProperty();
            observable.set(selectedEmployees.contains(item));
            observable.addListener((obs, wasSelected, isNowSelected) -> {
                if (isNowSelected)
                    selectedEmployees.add(item);
                else
                    selectedEmployees.remove(item);
                enableRemoveButton();
            });
            return observable;
        }
    }));
    securityCombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> __, String oldValue, String newValue) {
            enableFinishBtn();
        }
    });
    enableFinishBtn();
    enableRemoveButton();
}
Also used : JFXButton(com.jfoenix.controls.JFXButton) Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) GlyphsBuilder(de.jensd.fx.glyphs.GlyphsBuilder) JFXPasswordField(com.jfoenix.controls.JFXPasswordField) URL(java.net.URL) CheckBoxListCell(javafx.scene.control.cell.CheckBoxListCell) FXCollections(javafx.collections.FXCollections) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected) HashSet(java.util.HashSet) Logger(org.apache.log4j.Logger) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) ResourceBundle(java.util.ResourceBundle) Map(java.util.Map) SecurityQuestions(GuiUtils.SecurityQuestions) FontAwesomeIconView(de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView) ConnectionFailure(EmployeeDefs.AEmployeeException.ConnectionFailure) JFXComboBox(com.jfoenix.controls.JFXComboBox) Callback(javafx.util.Callback) CriticalError(SMExceptions.CommonExceptions.CriticalError) RadioButtonEnabler(GuiUtils.RadioButtonEnabler) StackTraceUtil(UtilsImplementations.StackTraceUtil) JFXListView(com.jfoenix.controls.JFXListView) FilteredList(javafx.collections.transformation.FilteredList) Manager(EmployeeImplementations.Manager) WorkerAlreadyExists(EmployeeDefs.AEmployeeException.WorkerAlreadyExists) FXML(javafx.fxml.FXML) InjectionFactory(UtilsImplementations.InjectionFactory) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) WorkerDoesNotExist(EmployeeDefs.AEmployeeException.WorkerDoesNotExist) RadioButton(javafx.scene.control.RadioButton) FontAwesomeIcon(de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon) IManager(EmployeeContracts.IManager) ObservableValue(javafx.beans.value.ObservableValue) Login(BasicCommonClasses.Login) ObservableList(javafx.collections.ObservableList) ChangeListener(javafx.beans.value.ChangeListener) JFXTextField(com.jfoenix.controls.JFXTextField) InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Callback(javafx.util.Callback) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) RadioButton(javafx.scene.control.RadioButton) FontAwesomeIconView(de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator)

Example 4 with RadioButton

use of javafx.scene.control.RadioButton in project TeachingInSimulation by ScOrPiOzzy.

the class JudgmentOption method createRadioButton.

private void createRadioButton(String text, boolean selected) {
    RadioButton button = new RadioButton(text);
    // 单选框要设置选中图标左右位置
    // for (Node child : button.getSkin().getNode().) {
    // if (child instanceof StackPane) {
    // child.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
    // }
    // }
    button.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
    button.getStyleClass().add("option");
    button.setUserData(text);
    button.setWrapText(true);
    button.setSelected(selected);
    group.getToggles().add(button);
    this.getChildren().add(button);
    VBox.setVgrow(button, Priority.ALWAYS);
}
Also used : RadioButton(javafx.scene.control.RadioButton)

Example 5 with RadioButton

use of javafx.scene.control.RadioButton in project jphp by jphp-compiler.

the class RadioGroupPane method updateUi.

protected void updateUi(ObservableList<? extends T> list) {
    T selected = getSelected();
    buttons.clear();
    getChildren().clear();
    ObservableList<Node> children = getChildren();
    if (orientation == Orientation.HORIZONTAL) {
        final HBox hBox = new HBox();
        hBox.setSpacing(getSpacing());
        hBox.setPrefWidth(-1);
        hBox.setPrefHeight(-1);
        hBox.setAlignment(Pos.BASELINE_LEFT);
        spacingProperty().addListener(new ChangeListener<Number>() {

            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                hBox.setSpacing(newValue.intValue());
            }
        });
        children.add(hBox);
        children = hBox.getChildren();
    }
    for (T t : list) {
        String label = "" + t;
        RadioButton button = new RadioButton(label);
        button.setToggleGroup(group);
        button.setUserData(t);
        button.setFont(font);
        button.setTextFill(textColor);
        buttons.add(button);
        children.add(button);
    }
    setSelected(selected);
}
Also used : HBox(javafx.scene.layout.HBox) Node(javafx.scene.Node) RadioButton(javafx.scene.control.RadioButton)

Aggregations

RadioButton (javafx.scene.control.RadioButton)24 Insets (javafx.geometry.Insets)9 Label (javafx.scene.control.Label)7 ToggleGroup (javafx.scene.control.ToggleGroup)5 HBox (javafx.scene.layout.HBox)5 JFXRadioButton (com.jfoenix.controls.JFXRadioButton)4 Button (javafx.scene.control.Button)4 VBox (javafx.scene.layout.VBox)4 AutoTooltipRadioButton (bisq.desktop.components.AutoTooltipRadioButton)3 ObservableValue (javafx.beans.value.ObservableValue)3 ActionEvent (javafx.event.ActionEvent)3 Node (javafx.scene.Node)3 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)2 EasingInterpolator (com.almasb.fxgl.animation.EasingInterpolator)2 RequiredFieldValidator (com.jfoenix.validation.RequiredFieldValidator)2 FontAwesomeIconView (de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView)2 ArrayList (java.util.ArrayList)2 FXCollections (javafx.collections.FXCollections)2 ObservableList (javafx.collections.ObservableList)2 CheckBox (javafx.scene.control.CheckBox)2