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;
}
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();
}
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;
}
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);
}
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();
}
}
Aggregations