1

I have a table in a JavaFX application where I want to be able to change the color of the selected element with a color picker.

When I try the following:

menuBar.setStyle("-fx-background-color:" + settings.getRgbString(memberView.colorPicker.getValue()));

There is no way to add the style just to the selected item. I tried to use a pseudo class but I can't understand how to do it. How do I solve this?

Note: changing the background of buttons works fine with this method.

CyanCoding
  • 1,012
  • 1
  • 12
  • 35
Vahn Toan
  • 93
  • 10
  • Possible duplicate of [Colouring table row in JavaFX](https://stackoverflow.com/questions/32119277/colouring-table-row-in-javafx) – ZeldaZach Jun 21 '17 at 20:09
  • 1
    It's not entirely clear exactly what functionality you're looking for. Try also https://stackoverflow.com/questions/20350099/programmatically-change-the-tableview-row-appearance – James_D Jun 21 '17 at 20:30

1 Answers1

0

try to add a css file to the project and put

.table-row-cell:selected .table-cell {
    -fx-background-color: #FF9034;
    -fx-text-fill: #FFF;
}
FiliusBonacci
  • 104
  • 1
  • 7