Styling list-cell of javafx listview with custom style class - css

I have a JavaFX ListView with an custom styleclass (selectlist). This should be styled different to all other ListViews in the application.
How can I style it's cells?
I have tried thisone in css file, but doesn't work:
.list-cell:even > .selectlist {
-fx-background-color: white;
}
.list-cell:odd > .selectlist{
-fx-background-color: white;
}
Would be nice if you could give me a hint...
Thanks in advance

Related

ngx-charts-gauge title color is unable to modify

I'm trying to add ngx-charts-gauge on angular5 app page.
Following these : https://swimlane.gitbooks.io/ngx-charts/content/charts/gauge.html
Everything works fine except I don't find any way or attribute or info to change Big center title color...It stills black !
I tried to override css class...with no chance.
.chart-container {
color: white;
}
Any help would be appreciated.
Thanks.
Change your css as below it will work
:host /deep/ .chart-container {
color: white;
}
OR
:host ::ng-deep .chart-container {
color: white;
}
Reason: Component style only applies to the html in component.
To force a style down to the child component use /deep/
documentation, another reference

JavaFX how to style the button part of a checkbox?

I am trying to do some css styling in a stylesheet for a JavaFX scene.
It is going to be loaded upon opening the scene, and targets all the "basic" elements of a scene.
My problem is that i can't seem to find the right combination of code, to change the background color, of the button in a standard JavaFX checkbox.
This is where i am now:
.check-box:selected{
-fx-background-color: #00FF00;
}
I have tried some variants of the above, like
.check-box .button{
-fx-fill: #00FF00;
-fx-background-color: #00FF00;
}
and others, but without success.
So in general, how do i access a button in a checkbox?
Thank you in advance :-)
The parts of the CheckBox to apply the -fx-background-color to are .box and .box > .mark in case you want to change the mark color:
.check-box:selected > .box {
/* background color for selected checkbox */
-fx-background-color: lime;
}
.check-box > .box {
/* background color of unselected checkbox */
-fx-background-color: red;
}
.check-box:selected > .box > .mark,
.check-box:indeterminate > .box > .mark {
/* modify mark color */
-fx-background-color: blue;
}

ButtonType ButtonData.OK CSS JavaFX Alert

I'm trying to style ma Alert in JavaFX. My buttons in general are alright. This is what I have in my Java Class:
alert.getDialogPane().getStylesheets().add("/gui/style.css");
ButtonType importButtonType = new ButtonType("Importeer", ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType("Annuleer", ButtonData.CANCEL_CLOSE);
alert.getDialogPane().getButtonTypes().setAll(importButtonType, cancelButtonType);
And this is what I have in my CSS :
.dialog-pane .button {
-fx-font-family: 'Open Sans', sans-serif;
-fx-font-size: 14;
-fx-text-fill: #55595c;
-fx-background-color: #d0d0d0;
}
But I want to style my ButtonType with the ButtonData.OK_DONE in a different style. Any Ideas how?
I had the same problem and I found the solution by myself.
If someone is still interested :
Button okBtn = (Button) alert.getDialogPane().lookupButton(alert.getButtonTypes().get(index_of_the_OK_button));
okBtn.getStyleClass().add(your_custom_class);
with your custom class in your css file, it should work :)
To change the default button used in dialog/alerts, you can add the following to your css file.
.root { -fx-default-button: red; }
Another option would be to add the following:
.button:default { -fx-base: red; }

QT Style QPushButton differently whether has Icon or not?

Is it possible to style QPushButtons separately from a qss stylesheet whether it has an icon applied or not?
Something like:
QPushButton[hasIcon="true"] {
background-color: green;
}
QPushButton[hasIcon="false"] {
background-color: red;
}
Thank you!

JavaFX with FXML change css file runtime, with menu-items

I'm learing JavaFx and I'm trying to change the css style of my window (Mastermind game) at runtime.
Currently it works with some objects like buttons, background, menu bar, labels and shapes.
But another object I'd like to change is the menu items (background and labels).
I've tried to use the next css code to acces it :
.context-menu {
-fx-background-color: linear-gradient(rgba(200,200,200,1),rgba(50,50,50,1) 80%);
}
It works on initalisation but not when changed at runtime.
For example, it works fine for the menu bar itself :
.menu-bar {
-fx-background-color: black;
-fx-selection-bar: #505050;
}
.menu-bar .label {
-fx-font-size: 12pt;
-fx-font-family: "Segoe UI Light";
-fx-text-fill: white;
-fx-opacity: 0.9;
}
In the FXMLcontroller I call the following code to change the skin :
#FXML private AnchorPane generalPane;
private final String themeNormal = getClass().getResource("/mastermindStyles/MasterMind_Normal.css").toExternalForm();
#FXML
void handleSkinNormal(ActionEvent event){
generalPane.getStylesheets().clear();
generalPane.getStylesheets().add(themeNormal);
}
How can I do it?
I've found it :
To use predefinite styles (like Modena and Caspian) :
Application.setUserAgentStylesheet(STYLESHEET_MODENA);
To use your own css stylesheet :
Application.setUserAgentStylesheet(null);
StyleManager.getInstance().addUserAgentStylesheet(
getClass().getResource("NewSkin.css").toExternalForm());

Resources