Search in sources :

Example 6 with RadioButton

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

the class ManagePackagesTab 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]", ""));
        showScanCodePane(true);
        resetParams();
        searchCodeButton.setDisable(newValue.isEmpty());
    });
    editPackagesAmountSpinner.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
    editPackagesAmountSpinner.valueProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue == null || newValue < 1)
            editPackagesAmountSpinner.getValueFactory().setValue(oldValue);
        enableRunTheOperationButton();
    });
    editPackagesAmountSpinner.focusedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null && !newValue) {
            editPackagesAmountSpinner.increment(0);
            enableRunTheOperationButton();
        }
    });
    final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {

        @Override
        public DateCell call(final DatePicker __) {
            return new DateCell() {

                @Override
                public void updateItem(LocalDate item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!item.isBefore(LocalDate.now()))
                        return;
                    setDisable(true);
                    setStyle("-fx-background-color: #EEEEEE;");
                }
            };
        }
    };
    datePicker.setDayCellFactory(dayCellFactory);
    datePicker.setValue(LocalDate.now());
    VBox vbox = new VBox();
    vbox.setPadding(new Insets(10, 50, 50, 50));
    vbox.setSpacing(10);
    datePickerForSmartCode = new JFXDatePicker();
    Label lbl = new Label("Choose Date");
    vbox.getChildren().addAll(lbl, datePickerForSmartCode);
    JFXPopup popup = new JFXPopup(vbox);
    showDatePickerBtn.setOnMouseClicked(e -> popup.show(showDatePickerBtn, PopupVPosition.TOP, PopupHPosition.LEFT));
    radioButtonContainerSmarcodeOperations.addRadioButtons(Arrays.asList(new RadioButton[] { printSmartCodeRadioButton, addPackageToStoreRadioButton, removePackageFromStoreRadioButton, removePackageFromWarhouseRadioButton }));
    radioButtonContainerBarcodeOperations.addRadioButtons(Arrays.asList(new RadioButton[] { addPakageToWarhouseRadioButton }));
    resetParams();
    showScanCodePane(true);
}
Also used : JFXDatePicker(com.jfoenix.controls.JFXDatePicker) JFXPopup(com.jfoenix.controls.JFXPopup) Callback(javafx.util.Callback) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) DatePicker(javafx.scene.control.DatePicker) JFXDatePicker(com.jfoenix.controls.JFXDatePicker) RadioButton(javafx.scene.control.RadioButton) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) DateCell(javafx.scene.control.DateCell) LocalDate(java.time.LocalDate) VBox(javafx.scene.layout.VBox)

Example 7 with RadioButton

use of javafx.scene.control.RadioButton 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

RadioButton (javafx.scene.control.RadioButton)7 JFXRadioButton (com.jfoenix.controls.JFXRadioButton)4 ObservableValue (javafx.beans.value.ObservableValue)3 RequiredFieldValidator (com.jfoenix.validation.RequiredFieldValidator)2 FontAwesomeIconView (de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView)2 ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)1 Login (BasicCommonClasses.Login)1 IManager (EmployeeContracts.IManager)1 ConnectionFailure (EmployeeDefs.AEmployeeException.ConnectionFailure)1 EmployeeNotConnected (EmployeeDefs.AEmployeeException.EmployeeNotConnected)1 InvalidParameter (EmployeeDefs.AEmployeeException.InvalidParameter)1 WorkerAlreadyExists (EmployeeDefs.AEmployeeException.WorkerAlreadyExists)1 WorkerDoesNotExist (EmployeeDefs.AEmployeeException.WorkerDoesNotExist)1 Manager (EmployeeImplementations.Manager)1 RadioButtonEnabler (GuiUtils.RadioButtonEnabler)1 SecurityQuestions (GuiUtils.SecurityQuestions)1 CriticalError (SMExceptions.CommonExceptions.CriticalError)1 InjectionFactory (UtilsImplementations.InjectionFactory)1 StackTraceUtil (UtilsImplementations.StackTraceUtil)1 MultiplierType (com.exalttech.trex.ui.MultiplierType)1