Style ChoiceBox in JavaFX


Question

How can you style a ChoiceBox in JavaFX with CSS? The only things I have found out is how to change the background and the text color.

// Background Color
.cb {
   -fx-background-color: #HEX;
}

// Text Color
.cb .label {
   -fx-text-fill
}

enter image description here

What I am still missing is the highlighting color when hovering the items and the background color of the dropdown list. Also the little arrow. Unfortunately I have found no documentation or anything that helps.

EDIT:

@James_D gave a great link to find out stylings: Modena.css

That way I figured out how to color the white background black.

.cb .context-menu {
   -fx-background-color: black;
}
1
3
7/23/2014 9:04:41 PM

Accepted Answer

For the highlighting color:

.cb .menu-item:focused {
  -fx-background-color: yellow ; /* for example */
}

The background color of the dropdown list:

.cb .context-menu {
    -fx-background-color: antiquewhite ;
}

For the arrow:

.cb {
  -fx-mark-color: green ;
}
2
7/23/2014 6:41:03 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon