Hello. Using jfoenix 8.0.8. Is there any way to put error-label inside its text field?

Hi,
this is a little bit difficult but possible.
Unfortunately there is no CSS class for the ValidationPane or errorContainer in JFXTextField (I didn't found one maybe there is one :wink: ).
Only for the ValidationPane "error-label-container", "error-label" which doesn't help if we want to change the entire position.
So I wrote a method which access directly the Skin childs.
Be careful with it because it can fail in the future with other jfoenix versions if the related Skin class childs will change.
private <T extends TextField & IFXLabelFloatControl> void validationPaneFormatter(
T jfxTextField) {
jfxTextField
.skinProperty()
.addListener(
(observable, oldValue, newValue) -> {
JFXTextFieldSkin textFieldSkin = ((JFXTextFieldSkin) newValue);
ObservableList childs = textFieldSkin.getChildren();
// Get validation pane.
// It's always the last child. Be careful no get per type checking -> index can change
// -> code will fail.
ValidationPane validationPane = (ValidationPane) childs.get(childs.size() - 1);
validationPane.setTranslateY(-24);
// Set validation label to the right.
// Again node is always first child but code can fail in future.
StackPane labelStackPane = (StackPane) validationPane.getChildren().get(0);
labelStackPane.setAlignment(Pos.TOP_RIGHT);
});
// Validate also directly on typing or better text change for not override the error label.
jfxTextField
.textProperty()
.addListener((observable, oldValue, newValue) -> jfxTextField.validate());
}
Use it like:
...
JFXTextField validationField = new JFXTextField();
validationPaneFormatter(validationField);
...
Tested with JFXTextField demo:
Before:

After:

Greetings
ValidationPane validationPane = (ValidationPane) childs.get(childs.size() - 1); validationPane.setTranslateY(-24);
This part works fine, my error-label moves up and it's great.
StackPane labelStackPane = (StackPane) validationPane.getChildren().get(0); labelStackPane.setAlignment(Pos.TOP_RIGHT);
But there is a problem. It seems to me error-label or labelStackPane don't fill the parrent and error-text is on the left side.

Of course, i can set pref, min and max size of error-label inside the CSS, but i believe it's the wrong way
Hi,
yep I'm sorry and it's also funny :smile:
Because the code was broken for the current jfoenix version and I commented like "..can be broken in future":wink:
So the reason is that I'm working on the current master and didn't notice that there was a code change 10 days before (c6747d9445bcbaaa06555d97ecee70f8a61530e7). But this change is not in the current release version.
Here is the correct method which should work with the current release and also the new code version ... so currently :smile:
private <T extends TextField & IFXLabelFloatControl> void validationPaneFormatter(
T jfxTextField) {
jfxTextField
.skinProperty()
.addListener(
(observable, oldValue, newValue) -> {
JFXTextFieldSkin textFieldSkin = ((JFXTextFieldSkin) newValue);
ObservableList childs = textFieldSkin.getChildren();
// Get validation pane.
// It's always the last child. Be careful no get per type checking -> index can change
// -> code will fail.
ValidationPane validationPane = (ValidationPane) childs.get(childs.size() - 1);
validationPane.setTranslateY(-24);
// Set validation label to the right.
// Again node is always first child but code can fail in future.
StackPane labelStackPane = (StackPane) validationPane.getChildren().get(0);
Label innerErrorLabel = (Label) labelStackPane.getChildren().get(0);
StackPane.setAlignment(innerErrorLabel, Pos.TOP_RIGHT);
});
// Validate also directly on typing or better text change for not override the error label.
jfxTextField
.textProperty()
.addListener((observable, oldValue, newValue) -> jfxTextField.validate());
}
Greetings
So does it work like you want?
Greetings