1

Using JavaFX when I create a TextField and set

numberField.setFocusTraversable(false);

and then click on the field the blue box shows up around it. I guess that makes sense but there is no

setFocus(bool)

command.

I want to get rid of the box. Any suggestions?

BAR
  • 15,909
  • 27
  • 97
  • 185

1 Answers1

7

The setFocusTraversable(false) disables the focus traversing (by TAB and SHIFT+TAB) for that node. Thus it has nothing related with node's GUI style. To hide the focused blue color do:
Via code

numberField.setStyle("-fx-focus-color: transparent;");

or via css file

.text-field {
    -fx-focus-color: transparent;
}

or pseudo class in css file

.text-field:focused{
     -fx-focus-color: transparent;
}

-fx-focus-color is not a css property, it is a predefined color of caspian.css (JavaFX 2).

This answer is related to and referenced from: How do I remove the default border glow of a JavaFX button (when selected)?.

Community
  • 1
  • 1
Uluk Biy
  • 48,655
  • 13
  • 146
  • 153