Style ChoiceBox in JavaFX - java

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
}
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;
}

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 ;
}

Related

how to set default color of hyperlink in javafx?

How do I set hyperlink color to black, which is by default blue?
source=new Hyperlink("source"); source.setFont(Font.font("Arial", 20));
source.setLayoutX(920); source.setLayoutY(900);
source.setTooltip(new Tooltip("Github"));
layout.getChildren().add(source); // here layout is Pane layout
I want to set the color of source hyperlink to black.
You can change it in CSS:
.hyperlink {
-fx-text-fill: black;
}

JavaFX is there anyway to set the two colors of a selected treeview item using css

Is there any way to change the color of a selected TreeView item, instead of the default red and blue color that shows when a TreeItem is selected
This is not a standard java TreeView, I noticed that you're using JFoenix's tree view JFXTreeView. You can change the color of this selection bar by applying:
.tree-cell .selection-bar {
-fx-background-color: green;
}
To change that background color:
.tree-cell:selected {
-fx-background-color: green;
}

Selecting a TreeTableRow does not change background color

I tried to implement different coloring of my TreeTableView since there are DummyElements that should be separated visually from the other elements. Since they still are editable and stuff, there also has to be a certain style when they are selected. I tried the follownig:
.tree-table-row-cell:selected .text {
-fx-fill: white ;
}
.tree-table-row-cell .tree-table-cell:selected {
-fx-background-color: grey
}
.tree-table-cell .text {
-fx-fill: black ;
}
.tree-table-cell {
-fx-background-color: gainsboro
}
I dont know why, but the text color changes but the backgroundcolor
doesnt. Why is this?
Okay as always, when I post something here on SO, i find the answer shortly after, but since this is not very intuitive I wanted to share the solution.
.tree-table-row-cell:selected .text {
-fx-fill: white ;
}
.tree-table-row-cell:selected .tree-table-cell {
-fx-background-color: grey
}
.tree-table-cell .text {
-fx-fill: black ;
}
.tree-table-cell {
-fx-background-color: gainsboro
}
You want the to change the fx-background-color property of the tree-table-cell of the tree-table-row-cell:selected pseudo class.
You DONT want to change the fx-background-color property of the tree-table-cell:selected pseudo class since it doest no exist (afaik).
The thing is, that naming of all classes is a bit weird in javaFX...

JavaFX: is it possible to set a background color for an entire TreeView?

I have tried the following with no success:
.tree-view {
-fx-skin: "com.sun.javafx.scene.control.skin.TreeViewSkin";
-fx-background-color: green, -fx-control-inner-background;
-fx-background-insets: 0, 1;
}
What I am trying to achieve is to set a blue background for an entire TreeView except the selected one. Setting the background on the selected tree item works fine, but changing for the entire tree view does not have any effect.
You can color the individual TreeCells by using the .tree-cell selector:
.tree-view {
-fx-background-color:lightsteelblue;
}
.tree-cell {
-fx-background-color:lightsteelblue; // Default color
}
.tree-view:focused .tree-cell:filled:selected {
-fx-background-color:indigo; // Focused color
}
.tree-cell:filled:selected{
-fx-background-color:lightcyan; // Unfocused color
}
Produces something like this:

Checkbox background size in JavaFx-Css

I am styling a checkbox inside a menu button, and i am trying to change the color of the box's background but it appears the size of it (red) is larger than the margin (yellow), how can I change the size or what would be the attribute to change? I tried changing the size attribute in CSS but it is not working.
.menu-item .check-box > .box {
-fx-background-color: red;
-fx-border-color: yellow;
}
Example Link

Categories

Resources