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