Basically I have changed the css for a text field in javafx by adding a style class like this:
textfield.getStyleClass().add("textfieldstyle");
But then I want to be able to revert it back to its original appearance. But since the original appearance in this case is the default skin for JavaFX, I can't find the original layout for the textfields. I found the textfieldskin properties here, but its a jungle, and I can't find anything about the color of the -fx-control-inner-background, -fx-text-box-border and -fx-focus-color, which is what I want to know.
I've triedtextfield.getStyleClass().remove("textfieldstyle");
and think that does remove the new css, but it doesn't apply the old one again.
Use the inherit keyword to make an element's property the same as its parent. Use the revert keyword to reset a property to the value established by the user-agent stylesheet (or by user styles, if any exist). Use the revert-layer keyword to reset a property to the value established in a previous cascade layer.
So if this was the first change you made, then all you'll need to do is select all the CSS in the main editor, then hit backspace to delete it and finally save to save the changes.
Thanks to the comments by @UlukBiy and @varren I solved the issue. System.out.println(textfield.getStyleClass());
was of great use since it allowed me to check which style classes were applied on the text field as default. And as it is pointed out in the comments those where text-input
and text-field
.
So to restore the text field's css to its default value I just did:
textfield.getStyleClass().clear();
textfield.getStyleClass().addAll("text-field", "text-input");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With