1

When I click on a row within a TableView the row will be highlighted blue. How is it possible to disable this feature? I've already tried to set the background to white, but the problem is that the row-color isn't white in every row. Does anybody know what to do?

best regards

EDIT:

In the image below you see the blue color of the second row. This highlighting should be removed.

enter image description here

S.Pro
  • 633
  • 2
  • 12
  • 23
  • what _do_ you want to achieve? Removing the visible clue for selection doesn't sound user-friendly – kleopatra Nov 19 '14 at 10:32
  • updated the question. hope this helps to understand my question. the point is that I have a TableView with some controls in the cells. so highlighting a row by clicking on them looks terrible and is distracting the user. – S.Pro Nov 19 '14 at 12:04
  • In addition to styling there's `TableView.getSelectionModel().setCellSelectionEnabled(true);` That makes just one cell highlighted. – brian Nov 19 '14 at 13:25
  • 1
    The point is that I want the program not to highlight anything. – S.Pro Nov 19 '14 at 13:31

1 Answers1

4

If you really want to do this (I agree with @kleopatra in the comments that it would make life difficult for the user) you can revert the colors for selected rows with an external css file:

.table-row-cell:filled:selected {
  -fx-background: -fx-control-inner-background ;
  -fx-background-color: -fx-table-cell-border-color, -fx-background ;
  -fx-background-insets: 0, 0 0 1 0 ;
  -fx-table-cell-border-color: derive(-fx-color, 5%);
}
.table-row-cell:odd:filled:selected {
  -fx-background: -fx-control-inner-background-alt ;
}
James_D
  • 201,275
  • 16
  • 291
  • 322
  • Works fine, but there are still borders around every cell in the marked row. `-fx-border-width: 0;` and `-fx-border-color: transparent;` didn't help. Do you know what to do? – S.Pro Nov 19 '14 at 13:03
  • Updated. Sometimes it's useful to look at how styles are defined in the [default stylesheet](http://hg.openjdk.java.net/openjfx/8/master/rt/file/f89b7dc932af/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css) – James_D Nov 19 '14 at 13:13
  • I was trying to find an "elegant" way to get this to work; but you're right, just changing the `-fx-selection-bar` leaves a subtle change. I think the only way is to revert everything that is set for selected cells. This seems to work for me: I can't tell at all which row is selected... – James_D Nov 19 '14 at 14:55