Search in sources :

Example 16 with JFXTextField

use of com.jfoenix.controls.JFXTextField in project JFoenix by jfoenixadmin.

the class JFXTextFieldSkin method computeMinWidth.

@Override
protected double computeMinWidth(double h, double topInset, double rightInset, double bottomInset, double leftInset) {
    final double w = super.computeMinWidth(h, topInset, rightInset, bottomInset, leftInset);
    Node leadingGraphic = ((JFXTextField) getSkinnable()).getTrailingGraphic();
    Node trailingGraphic = ((JFXTextField) getSkinnable()).getTrailingGraphic();
    final double leadingW = leadingGraphic == null ? 0.0 : snapSize(leadingGraphic.minWidth(h));
    final double trailingW = trailingGraphic == null ? 0.0 : snapSize(trailingGraphic.minWidth(h));
    return w + trailingW + leadingW;
}
Also used : Node(javafx.scene.Node) JFXTextField(com.jfoenix.controls.JFXTextField)

Example 17 with JFXTextField

use of com.jfoenix.controls.JFXTextField in project JFoenix by jfoenixadmin.

the class JFXDatePickerSkin method handleControlPropertyChanged.

@Override
protected void handleControlPropertyChanged(String p) {
    if ("DEFAULT_COLOR".equals(p)) {
        ((JFXTextField) getEditor()).setFocusColor(jfxDatePicker.getDefaultColor());
    } else if ("DAY_CELL_FACTORY".equals(p)) {
        updateDisplayNode();
        content = null;
        popup = null;
    } else if ("CONVERTER".equals(p)) {
        updateDisplayNode();
    } else if ("EDITOR".equals(p)) {
        getEditableInputNode();
    } else if ("SHOWING".equals(p)) {
        if (jfxDatePicker.isShowing()) {
            if (content != null) {
                LocalDate date = jfxDatePicker.getValue();
                // set the current date / now when showing the date picker content
                content.displayedYearMonthProperty().set((date != null) ? YearMonth.from(date) : YearMonth.now());
                content.updateValues();
            }
            show();
        } else {
            hide();
        }
    } else if ("SHOW_WEEK_NUMBERS".equals(p)) {
        if (content != null) {
            // update the content grid to show week numbers
            content.updateContentGrid();
            content.updateWeekNumberDateCells();
        }
    } else if ("VALUE".equals(p)) {
        updateDisplayNode();
        if (content != null) {
            LocalDate date = jfxDatePicker.getValue();
            content.displayedYearMonthProperty().set((date != null) ? YearMonth.from(date) : YearMonth.now());
            content.updateValues();
        }
        jfxDatePicker.fireEvent(new ActionEvent());
    } else {
        super.handleControlPropertyChanged(p);
    }
}
Also used : ActionEvent(javafx.event.ActionEvent) JFXTextField(com.jfoenix.controls.JFXTextField) LocalDate(java.time.LocalDate)

Example 18 with JFXTextField

use of com.jfoenix.controls.JFXTextField in project JFoenix by jfoenixadmin.

the class IntegerTextFieldEditorBuilder method createNode.

@Override
public Region createNode(Integer value, DoubleBinding minWidthBinding, EventHandler<KeyEvent> keyEventsHandler, ChangeListener<Boolean> focusChangeListener) {
    StackPane pane = new StackPane();
    pane.setStyle("-fx-padding:-10 0 -10 0");
    textField = new JFXTextField(value + "");
    textField.minWidthProperty().bind(minWidthBinding);
    textField.setOnKeyPressed(keyEventsHandler);
    textField.focusedProperty().addListener(focusChangeListener);
    NumberValidator validator = new NumberValidator();
    validator.setMessage("Value must be a number");
    textField.getValidators().add(validator);
    pane.getChildren().add(textField);
    return pane;
}
Also used : NumberValidator(com.jfoenix.validation.NumberValidator) JFXTextField(com.jfoenix.controls.JFXTextField) StackPane(javafx.scene.layout.StackPane)

Example 19 with JFXTextField

use of com.jfoenix.controls.JFXTextField in project JFoenix by jfoenixadmin.

the class TextFieldEditorBuilder method createNode.

@Override
public Region createNode(String value, DoubleBinding minWidthBinding, EventHandler<KeyEvent> keyEventsHandler, ChangeListener<Boolean> focusChangeListener) {
    StackPane pane = new StackPane();
    pane.setStyle("-fx-padding:-10 0 -10 0");
    textField = new JFXTextField(value);
    textField.setStyle("-fx-background-color:TRANSPARENT;");
    textField.minWidthProperty().bind(minWidthBinding);
    textField.setOnKeyPressed(keyEventsHandler);
    textField.focusedProperty().addListener(focusChangeListener);
    pane.getChildren().add(textField);
    return pane;
}
Also used : JFXTextField(com.jfoenix.controls.JFXTextField) StackPane(javafx.scene.layout.StackPane)

Example 20 with JFXTextField

use of com.jfoenix.controls.JFXTextField in project JFoenix by jfoenixadmin.

the class JFXTextFieldSkin method createFloatingLabel.

private void createFloatingLabel() {
    if (((JFXTextField) getSkinnable()).isLabelFloat()) {
        if (promptText == null) {
            // get the prompt text node or create it
            boolean triggerFloatLabel = false;
            if (textPane.getChildren().get(0) instanceof Text)
                promptText = (Text) textPane.getChildren().get(0);
            else {
                Field field;
                try {
                    field = TextFieldSkin.class.getDeclaredField("promptNode");
                    field.setAccessible(true);
                    createPromptNode();
                    field.set(this, promptText);
                    // position the prompt node in its position
                    triggerFloatLabel = true;
                } catch (NoSuchFieldException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (SecurityException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalArgumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            promptText.getTransforms().add(promptTextScale);
            promptContainer.getChildren().add(promptText);
            if (triggerFloatLabel) {
                promptText.setTranslateY(-textPane.getHeight());
                promptTextScale.setX(0.85);
                promptTextScale.setY(0.85);
            }
        }
        promptTextUpTransition = new CachedTransition(textPane, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptText.translateYProperty(), -textPane.getHeight(), Interpolator.EASE_BOTH), new KeyValue(promptTextScale.xProperty(), 0.85, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.yProperty(), 0.85, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(240));
            }
        };
        promptTextColorTransition = new CachedTransition(textPane, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptTextFill, ((JFXTextField) getSkinnable()).getFocusColor(), Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(160));
            }

            protected void starting() {
                super.starting();
                oldPromptTextFill = promptTextFill.get();
            }

            ;
        };
        promptTextDownTransition = new CachedTransition(textPane, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptText.translateYProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.xProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.yProperty(), 1, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(240));
            }
        };
        promptTextDownTransition.setOnFinished((finish) -> {
            promptText.setTranslateY(0);
            promptTextScale.setX(1);
            promptTextScale.setY(1);
        });
        promptText.visibleProperty().unbind();
        promptText.visibleProperty().set(true);
    }
}
Also used : TextFieldSkin(com.sun.javafx.scene.control.skin.TextFieldSkin) JFXTextField(com.jfoenix.controls.JFXTextField) Text(javafx.scene.text.Text) Field(java.lang.reflect.Field) JFXTextField(com.jfoenix.controls.JFXTextField) CachedTransition(com.jfoenix.transitions.CachedTransition)

Aggregations

JFXTextField (com.jfoenix.controls.JFXTextField)30 Node (javafx.scene.Node)11 Field (java.lang.reflect.Field)5 StackPane (javafx.scene.layout.StackPane)5 Insets (javafx.geometry.Insets)4 TextField (javafx.scene.control.TextField)4 VBox (javafx.scene.layout.VBox)4 Text (javafx.scene.text.Text)4 JFXButton (com.jfoenix.controls.JFXButton)3 JFXTreeView (com.jfoenix.controls.JFXTreeView)3 CachedTransition (com.jfoenix.transitions.CachedTransition)3 TextFieldSkin (com.sun.javafx.scene.control.skin.TextFieldSkin)3 Bindings (javafx.beans.binding.Bindings)3 ObjectProperty (javafx.beans.property.ObjectProperty)3 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)3 Scene (javafx.scene.Scene)3 Color (javafx.scene.paint.Color)3 JFXTreeViewPath (com.jfoenix.controls.JFXTreeViewPath)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2