Search in sources :

Example 1 with JFXTextField

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

the class JFXTextFieldSkinAndroid 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 : JFXTextFieldSkin(com.jfoenix.skins.JFXTextFieldSkin) 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)

Example 2 with JFXTextField

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

the class JFXTextFieldOldSkin 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();
                }
            }
            promptContainer.getChildren().add(promptText);
            if (triggerFloatLabel) {
                promptText.setTranslateY(-textPane.getHeight());
                promptText.setTranslateX(-(promptText.getLayoutBounds().getWidth() * 0.15) / 2);
                promptText.setLayoutY(0);
                promptText.setScaleX(0.85);
                promptText.setScaleY(0.85);
            }
        }
        promptTextUpTransition = new CachedTransition(textPane, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptText.translateYProperty(), -textPane.getHeight(), Interpolator.EASE_BOTH), new KeyValue(promptText.translateXProperty(), -(promptText.getLayoutBounds().getWidth() * 0.15) / 2, Interpolator.EASE_BOTH), new KeyValue(promptText.scaleXProperty(), 0.85, Interpolator.EASE_BOTH), new KeyValue(promptText.scaleYProperty(), 0.85, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(300));
            }
        };
        promptTextColorTransition = new CachedTransition(textPane, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptTextFill, focusedLine.getStroke(), Interpolator.EASE_BOTH)))) {

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

            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(promptText.translateXProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(promptText.scaleXProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(promptText.scaleYProperty(), 1, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(300));
            }
        };
        promptTextDownTransition.setOnFinished((finish) -> {
            promptText.setTranslateX(0);
            promptText.setTranslateY(0);
            promptText.setScaleX(1);
            promptText.setScaleY(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)

Example 3 with JFXTextField

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

the class DoubleTextFieldEditorBuilder method createNode.

@Override
public Region createNode(Double 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);
    DoubleValidator validator = new DoubleValidator();
    validator.setMessage("Value must be a rational number");
    textField.getValidators().add(validator);
    pane.getChildren().add(textField);
    return pane;
}
Also used : DoubleValidator(com.jfoenix.validation.DoubleValidator) JFXTextField(com.jfoenix.controls.JFXTextField) StackPane(javafx.scene.layout.StackPane)

Example 4 with JFXTextField

use of com.jfoenix.controls.JFXTextField in project SmartCity-Market by TechnionYP5777.

the class GettingPasswordScreen method getContent.

@Override
Parent getContent() {
    usernameField = new JFXTextField();
    usernameField.textProperty().addListener((observable, oldValue, newValue) -> nextButton.setDisable(newValue.isEmpty()));
    VBox vbox = new VBox(5, new Label("Enter Username"), usernameField);
    vbox.setAlignment(Pos.CENTER);
    return vbox;
}
Also used : JFXTextField(com.jfoenix.controls.JFXTextField)

Example 5 with JFXTextField

use of com.jfoenix.controls.JFXTextField in project SmartCity-Market by TechnionYP5777.

the class ManageCatalogProductDetailsTab method initialize.

@Override
public void initialize(URL location, ResourceBundle __) {
    createManufacturerList();
    createIngredientList();
    filterManu.textProperty().addListener(obs -> {
        String filter = filterManu.getText();
        filteredDataManu.setPredicate(filter == null || filter.length() == 0 ? s -> true : s -> s.contains(filter));
    });
    manufacturerList.setCellFactory(CheckBoxListCell.forListView(new Callback<String, ObservableValue<Boolean>>() {

        @Override
        public ObservableValue<Boolean> call(String item) {
            BooleanProperty observable = new SimpleBooleanProperty();
            observable.set(selectedManu.contains(item));
            observable.addListener((obs, wasSelected, isNowSelected) -> {
                if (isNowSelected)
                    selectedManu.add(item);
                else
                    selectedManu.remove(item);
                enableButtons();
            });
            return observable;
        }
    }));
    filterIngr.textProperty().addListener(obs -> {
        String filter = filterIngr.getText();
        filteredDataIngr.setPredicate(filter == null || filter.length() == 0 ? s -> true : s -> s.contains(filter));
    });
    ingredientsList.setCellFactory(CheckBoxListCell.forListView(new Callback<String, ObservableValue<Boolean>>() {

        @Override
        public ObservableValue<Boolean> call(String item) {
            BooleanProperty observable = new SimpleBooleanProperty();
            observable.set(selectedIngr.contains(item));
            observable.addListener((obs, wasSelected, isNowSelected) -> {
                if (isNowSelected)
                    selectedIngr.add(item);
                else
                    selectedIngr.remove(item);
                enableButtons();
            });
            return observable;
        }
    }));
    Label lbl1 = new Label("Insert New Manufacturar");
    newManu = new JFXTextField();
    okNewManu = new JFXButton("Done!");
    okNewManu.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent __) {
            addManuPressed();
        }
    });
    VBox manuContainer = new VBox();
    manuContainer.getChildren().addAll(lbl1, newManu, okNewManu);
    manuContainer.setPadding(new Insets(10, 50, 50, 50));
    manuContainer.setSpacing(10);
    JFXPopup popup1 = new JFXPopup(manuContainer);
    addManuBtn.setOnMouseClicked(e -> popup1.show(addManuBtn, PopupVPosition.TOP, PopupHPosition.LEFT));
    newManu.textProperty().addListener((observable, oldValue, newValue) -> enableAddButtons());
    Label lbl2 = new Label("Insert New Ingredient");
    newIngr = new JFXTextField();
    okNewIngr = new JFXButton("Done!");
    okNewIngr.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent __) {
            addIngPressed();
        }
    });
    VBox ingrContainer = new VBox();
    ingrContainer.getChildren().addAll(lbl2, newIngr, okNewIngr);
    ingrContainer.setPadding(new Insets(10, 50, 50, 50));
    ingrContainer.setSpacing(10);
    JFXPopup popup2 = new JFXPopup(ingrContainer);
    addIngrBtn.setOnMouseClicked(e -> popup2.show(addIngrBtn, PopupVPosition.TOP, PopupHPosition.LEFT));
    newIngr.textProperty().addListener((observable, oldValue, newValue) -> enableAddButtons());
    Label lbl3 = new Label("Rename Selected Manufacturar");
    renameManuLbl = new JFXTextField();
    okRenameManu = new JFXButton("Done!");
    okRenameManu.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent __) {
            renameManuPressed();
        }
    });
    VBox renameManuContainer = new VBox();
    renameManuContainer.getChildren().addAll(lbl3, renameManuLbl, okRenameManu);
    renameManuContainer.setPadding(new Insets(10, 50, 50, 50));
    renameManuContainer.setSpacing(10);
    JFXPopup popup3 = new JFXPopup(renameManuContainer);
    renameManu.setOnMouseClicked(e -> popup3.show(renameManu, PopupVPosition.TOP, PopupHPosition.LEFT));
    renameManuLbl.textProperty().addListener((observable, oldValue, newValue) -> enableAddButtons());
    Label lbl4 = new Label("Rename Selected Ingredient");
    renameIngrLbl = new JFXTextField();
    okRenameIngr = new JFXButton("Done!");
    okRenameIngr.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent __) {
            renameIngrPressed();
        }
    });
    VBox renameIngrContainer = new VBox();
    renameIngrContainer.getChildren().addAll(lbl4, renameIngrLbl, okRenameIngr);
    renameIngrContainer.setPadding(new Insets(10, 50, 50, 50));
    renameIngrContainer.setSpacing(10);
    JFXPopup popup4 = new JFXPopup(renameIngrContainer);
    renameIngr.setOnMouseClicked(e -> popup4.show(renameIngr, PopupVPosition.TOP, PopupHPosition.LEFT));
    renameIngrLbl.textProperty().addListener((observable, oldValue, newValue) -> enableAddButtons());
    enableButtons();
    enableAddButtons();
}
Also used : EventHandler(javafx.event.EventHandler) JFXButton(com.jfoenix.controls.JFXButton) Initializable(javafx.fxml.Initializable) URL(java.net.URL) CheckBoxListCell(javafx.scene.control.cell.CheckBoxListCell) PopupVPosition(com.jfoenix.controls.JFXPopup.PopupVPosition) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) Manufacturer(BasicCommonClasses.Manufacturer) VBox(javafx.scene.layout.VBox) JFXPopup(com.jfoenix.controls.JFXPopup) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected) HashSet(java.util.HashSet) ParamIDAlreadyExists(EmployeeDefs.AEmployeeException.ParamIDAlreadyExists) Logger(org.apache.log4j.Logger) Insets(javafx.geometry.Insets) ResourceBundle(java.util.ResourceBundle) ManfacturerStillInUse(EmployeeDefs.AEmployeeException.ManfacturerStillInUse) ConnectionFailure(EmployeeDefs.AEmployeeException.ConnectionFailure) ParamIDDoesNotExist(EmployeeDefs.AEmployeeException.ParamIDDoesNotExist) Callback(javafx.util.Callback) CriticalError(SMExceptions.CommonExceptions.CriticalError) Label(javafx.scene.control.Label) StackTraceUtil(UtilsImplementations.StackTraceUtil) JFXListView(com.jfoenix.controls.JFXListView) FilteredList(javafx.collections.transformation.FilteredList) Manager(EmployeeImplementations.Manager) IngredientStillInUse(EmployeeDefs.AEmployeeException.IngredientStillInUse) FXML(javafx.fxml.FXML) InjectionFactory(UtilsImplementations.InjectionFactory) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) PopupHPosition(com.jfoenix.controls.JFXPopup.PopupHPosition) IManager(EmployeeContracts.IManager) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) Ingredient(BasicCommonClasses.Ingredient) JFXTextField(com.jfoenix.controls.JFXTextField) InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) JFXPopup(com.jfoenix.controls.JFXPopup) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Insets(javafx.geometry.Insets) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ActionEvent(javafx.event.ActionEvent) JFXTextField(com.jfoenix.controls.JFXTextField) Label(javafx.scene.control.Label) JFXButton(com.jfoenix.controls.JFXButton) Callback(javafx.util.Callback) VBox(javafx.scene.layout.VBox)

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