How can I change the text color of the TableView component's header?
I tired this:
.table-view .column-header, .table-view .filler {
-fx-text-fill: white;
-fx-border-width: 0, 0;
-fx-font-size: 12px;
}
This remove the border, and also change the font size, but not the font color.
Something like this might work.
.table-view .column-header .label {
-fx-text-fill: white;
-fx-font-weight: bold;
}
#David Charles: style classes of the TableColumn also apply to the column header, so to style an individual column header, you can use
.table-view .column-header.foo .label {
-fx-text-fill: white;
-fx-font-weight: bold;
}
and in Java
tableColumn.getStyleClass().add("foo");
Related
I have a toolbar (VBox) with several JFXButtons. All button's caption and glyphs are white. I want to change only glyph color when mousepointer is over the button.
The CSS file:
.button {
-fx-text-fill: white;
-fx-fill: white;
}
.button .glyph-icon:hover {
-fx-background-color: derive(black, 15%);
-fx-fill: #cc8f1e;
}
change the 'color' property for glyph
Define the hover state of the button first, then another hover state with the glyph-icon, like this:
.button
{
-fx-text-fill: white;
-fx-fill: white;
}
.button:hover
{
-fx-background-color: derive(black, 15%);
-fx-fill: #cc8f1e;
}
.button:hover .glyph-icon, .button:hover .glyph-icon
{
-fx-text-fill: #cc8f1e;
}
I'm trying to set the text color of combobox.
My code, which I tried
comboList.setStyle("-fx-text-fill: blue");
Try it with
.combo-box .list-cell
{
-fx-background: white;
-fx-background-color: transparent;
-fx-text-fill: red;
}
The image shows what happens when a textfield is selected. It turns white although it should stay the same as the field above. Also the passwordfield shows strange icons - but thats another question.
Here the code:
.text-field {
-fx-background-color: rgba(0,0,0,0.1);
-fx-border-color: rgba(0,0,0,0.1);
-fx-background-radius:30;
-fx-border-radius:30;
-fx-min-height:45;
-fx-text-fill: #fff;
-fx-prompt-text-fill: #fff;
-fx-border-width:0px;
-fx-alignment: center;
-fx-font-size: 1.2em;
-fx-effect: null;
}
.text-field:hover,
.text-field:focused,
.text-field:selected {
-fx-background-color: rgba(0,0,0,0.1);
-fx-border-color: rgba(0,0,0,0.1);
-fx-background-radius:30;
-fx-border-radius:30;
-fx-min-height:45;
-fx-text-fill: #fff;
-fx-prompt-text-fill: #fff;
-fx-border-width:0px;
-fx-alignment: center;
-fx-font-size: 1.2em;
-fx-effect: null;
}
Is there anything wrong with my css or is it a bug maybe? Css is showing properly when i launch the app on desktop. But deployed the texfields are white.
Thanks for any help.
I am new to JavaFX and CSS Styling and was just after some clarification on the optimal way to do the following.
Essentially, I have two buttons which I have implemented Hover and Focus so the Border Color changes on both Hover (mouse) and Focused (Key Board Tab). Currently I have the following :
.normalbutton:hover {
-fx-font-size: 11pt;
-fx-font-family: "Verdana";
-fx-font-weight : Normal;
-fx-background-color : #545454;
-fx-border-color: #FFFFFF ;
-fx-border-radius: 3,3,3,3;
-fx-border-width: 1px ;
}
.normalbutton:focused {
-fx-font-size: 11pt;
-fx-font-family: "Verdana";
-fx-font-weight : Normal;
-fx-background-color : #545454;
-fx-border-color: #FFFFFF ;
-fx-border-radius: 3,3,3,3;
-fx-border-width: 1px ;
}
It works fine but I wan wondering if there was a way to combine both focused and hover as they have the same properties.
Multiple selectors can be seperated by , in CSS. If one of them matches, the the style is applied. In your example it would look like this:
.normalbutton:hover,
.normalbutton:focused {
-fx-font-size: 11pt;
-fx-font-family: "Verdana";
-fx-font-weight : Normal;
-fx-background-color : #545454;
-fx-border-color: #FFFFFF ;
-fx-border-radius: 3,3,3,3;
-fx-border-width: 1px ;
}
https://www.w3.org/TR/CSS21/selector.html#grouping
I have .css when the row is selected which is fine.
However when I click off the row it changes the row color grey with a black font, is there any way to edit this css?
.table-view {
-fx-base: transparent;
-fx-control-inner-background: transparent;
-fx-background-color: #507CA6;
-fx-padding: 5;
}
.table-view .column-header-background {
-fx-background-color: transparent;
}
.table-view .column-header, .table-view .filler {
-fx-size: 35;
-fx-border-width: 0 0 1 0;
-fx-background-color: transparent;
-fx-border-color: #B4D9FD;
-fx-border-insets: 0 10 1 0;
}
.table-view .column-header .label {
-fx-font-size: 14pt;
-fx-font-family: "Segoe UI Light";
-fx-text-fill: white;
-fx-alignment: center-left;
-fx-opacity: 1;
}
.table-view:focused .table-row-cell:filled:focused:selected {
-fx-background-color: #273D51;
}
Any help would be appreciated.
Try this:
/* When control is selected but not focused */
.table-row-cell:filled:selected,
.table-row-cell:filled > .table-cell:selected {
-fx-background: red;
}
first make selected class than use this script, i always use this $("tr").click(function(){
$(this).addClass("selected").siblings().removeClass("selected");
});