Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove borders from TextField

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;");
like image 804
user1285928 Avatar asked May 21 '14 10:05

user1285928


People also ask

How do I change the TextField border?

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.


Video Answer


1 Answers

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;
}
like image 72
Harald K Avatar answered Oct 05 '22 18:10

Harald K