Search in sources :

Example 11 with JFXTextField

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

the class JFXTextFieldSkinAndroid 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 12 with JFXTextField

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

the class TextFieldDemo method start.

@Override
public void start(Stage stage) throws Exception {
    final VBox pane = new VBox();
    pane.setSpacing(30);
    pane.setStyle("-fx-background-color:WHITE;-fx-padding:40;");
    pane.getChildren().add(new TextField());
    JFXTextField field = new JFXTextField();
    field.setLabelFloat(true);
    field.setPromptText("Type Something");
    pane.getChildren().add(field);
    JFXTextField disabledField = new JFXTextField();
    disabledField.setStyle(FX_LABEL_FLOAT_TRUE);
    disabledField.setPromptText("I'm disabled..");
    disabledField.setDisable(true);
    pane.getChildren().add(disabledField);
    JFXTextField validationField = new JFXTextField();
    validationField.setPromptText("With Validation..");
    RequiredFieldValidator validator = new RequiredFieldValidator();
    validator.setMessage("Input Required");
    FontIcon warnIcon = new FontIcon(FontAwesomeSolid.EXCLAMATION_TRIANGLE);
    warnIcon.getStyleClass().add(ERROR);
    validator.setIcon(warnIcon);
    validationField.getValidators().add(validator);
    validationField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal) {
            validationField.validate();
        }
    });
    pane.getChildren().add(validationField);
    JFXPasswordField passwordField = new JFXPasswordField();
    passwordField.setStyle(FX_LABEL_FLOAT_TRUE);
    passwordField.setPromptText("Password");
    validator = new RequiredFieldValidator();
    validator.setMessage("Password Can't be empty");
    warnIcon = new FontIcon(FontAwesomeSolid.EXCLAMATION_TRIANGLE);
    warnIcon.getStyleClass().add(ERROR);
    validator.setIcon(warnIcon);
    passwordField.getValidators().add(validator);
    passwordField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal) {
            passwordField.validate();
        }
    });
    pane.getChildren().add(passwordField);
    final Scene scene = new Scene(pane, 600, 400, Color.WHITE);
    scene.getStylesheets().add(TextFieldDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX TextField Demo ");
    stage.setScene(scene);
    stage.setResizable(false);
    stage.show();
}
Also used : JFXTextField(com.jfoenix.controls.JFXTextField) FontIcon(org.kordamp.ikonli.javafx.FontIcon) JFXPasswordField(com.jfoenix.controls.JFXPasswordField) TextField(javafx.scene.control.TextField) JFXTextField(com.jfoenix.controls.JFXTextField) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator)

Example 13 with JFXTextField

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

the class JFXTextFieldSkin method computePrefWidth.

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

Example 14 with JFXTextField

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

the class JFXTextFieldSkin method computePrefHeight.

@Override
protected double computePrefHeight(double w, double topInset, double rightInset, double bottomInset, double leftInset) {
    final double h = super.computePrefHeight(w, topInset, rightInset, bottomInset, leftInset);
    Node leadingGraphic = ((JFXTextField) getSkinnable()).getTrailingGraphic();
    Node trailingGraphic = ((JFXTextField) getSkinnable()).getTrailingGraphic();
    final double leadingH = leadingGraphic == null ? 0.0 : snapSize(leadingGraphic.prefHeight(w));
    final double trailingH = trailingGraphic == null ? 0.0 : snapSize(trailingGraphic.prefHeight(w));
    return Math.max(Math.max(h, leadingH), trailingH);
}
Also used : Node(javafx.scene.Node) JFXTextField(com.jfoenix.controls.JFXTextField)

Example 15 with JFXTextField

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

the class JFXTextFieldSkin method layoutChildren.

@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
    final double height = getSkinnable().getHeight();
    final Node leadingGraphic = ((JFXTextField) getSkinnable()).getLeadingGraphic();
    final Node trailingGraphic = ((JFXTextField) getSkinnable()).getTrailingGraphic();
    final double leadingW = leadingGraphic == null ? 0.0 : snapSize(leadingGraphic.prefWidth(height));
    final double trailingW = trailingGraphic == null ? 0.0 : snapSize(trailingGraphic.prefWidth(height));
    final double textX = snapPosition(x) + leadingW;
    final double textW = w - snapSize(leadingW) - snapSize(trailingW);
    super.layoutChildren(textX, y, textW, h);
    linesWrapper.layoutLines(x, y, w, h, height, Math.floor(h));
    linesWrapper.layoutPrompt(textX, y, textW, h);
    errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
    // draw leading/trailing graphics
    if (leadingGraphic != null) {
        leadingGraphic.resizeRelocate(snappedLeftInset(), 0, leadingW, height);
    }
    if (trailingGraphic != null) {
        trailingGraphic.resizeRelocate(w - trailingW + snappedLeftInset(), 0, trailingW, height);
    }
    if (getSkinnable().getWidth() > 0) {
        updateTextPos();
    }
    linesWrapper.updateLabelFloatLayout();
    if (invalid) {
        invalid = false;
        // update validation container
        errorContainer.invalid(w);
        // focus
        linesWrapper.invalid();
    }
}
Also used : Node(javafx.scene.Node) JFXTextField(com.jfoenix.controls.JFXTextField)

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