Is there a way completely to remove the borders from TextField? For example I wan to display the text from this text:
TextField chartTitle = new TextField("Soem text");
chartTitle.setEditable(false);
chartTitle.setStyle("-fx-focus-color: transparent;");
You can change the TextField border color globally by defining the inputDecorationTheme and then adding the OutlineInputBorder widget. Inside the OutlineInputBorder widget, you can specify which type of border you want to change. for example, enabledBorder , focusedBorder , and so on, and then assign the color.
Try adding this to your CSS:
.text-field {
-fx-text-box-border: transparent;
}
If you also want to remove the focus ring, add (similar to what you have):
.text-field:focused {
-fx-focus-color: transparent;
}
Unfortunately, this will only remove the visible border, the insets will still be there. To remove completely, you have to add quite some CSS (easiest is to copy & paste from caspian.css
).
Something like:
.text-field {
-fx-background-color: -fx-control-inner-background;
-fx-background-insets: 0;
-fx-padding: 1 3 1 3;
}
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