in javafx, does anyone know the css selector for the color of the "default" button in an alert? The "Yes" button in light blue here:
The base color for a default button is set to the looked-up color -fx-default-button:
.button:default {
-fx-base: -fx-default-button;
}
which defaults to the light blue in your screenshot:
.root {
/* ... */
-fx-default-button: #ABD8ED;
/* ... */
}
(Code snippets from modena.css source.)
So you can just change the value of -fx-default-button on your root element.
Related
I have a JavaFX application using gradle. I have used an Accordion as container for my TitledPane for my menu. The problem is that I can't set the TitledPane height according to sum of it's content height.
For example TitledPane 1 has 3 button inside:
So I set the height manually. But for TitledPane 2 I need to set height exactly for 1 button and remove extra blank spaces:
How could I do that? By the way the button border of Accordion gets disappear when I expand any TitledPane. My tress structure of Accordion is:
I have tried using css like:
.accordion .titled-pane {
-fx-fit-to-height: true;
}
or:
.accordion .titled-pane {
-fx-fit-to-height: true;
}
or some other css codes.
I just want to change the color of the fill circle on a RadioButton. Surprisingly I couldn't find this in documentation. Is it possible?
I found this similar thread with a solution that is not working for me: CSS Change radio button color in JFXRadioButton
Here is how I have tried it (also tried other variations to no avail):
.radio-button .radio {
-fx-selected-color: yellow;
-fx-unselected-color: blue;
}
-jfx-selected-color and -jfx-unselected-color are not defined in JavaFX. They are attributes from JFoenix (docs). Also -fx-selected-color and -fx-unselected-color are not available in JavaFX.
To change the color of the dot in the RadioButton you can use the :selected pseudoclass like this (docs):
.radio-button:selected .radio .dot {
-fx-background-color: red;
-fx-background-insets: 0;
}
Additionally to the -fx-background-color you should set -fx-background-insets: 0;, because otherwise the dot is not exactly in the center anymore.
The result will look like this:
In my Eclipse RAP application I have a theme with declared CSS styles for controls Button, Combo ...
I have the following problem, creating controls (e.g. Button) with a FormToolkit the background and foreground color is ignored.
Normal Button:
new Button(parent, SWT.PUSH);
FormToolkit Button:
managedForm.getToolkit().createButton(parent, "search", SWT.PUSH);
This is the CSS that I use:
Button[PUSH] {
border: 1px solid #C5C5C5;
/* fancy test colors */
background-color: #0000ff;
color: #00ff00;
}
Normal Button
FormToolkit Button
This is especially bad because the hover effect is ignored as well. Is there a way to enforce the FormToolkit to also use the CSS styles?
I figured out a workaround, not the desired solution but works for now:
// hack to ensure CSS styles are used
toolkit.getColors().setBackground(null);
toolkit.getColors().setForeground(null);
If the colors are set to null, CSS style is used.
This CSS code changes the text color of the whole text of a MenuItem:
.context-menu .label {
-fx-text-fill: blue;
}
The thing is that I only want to change the Accelerator display text.
The CSS reference of JavaFX was not very helpful: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#contextmenu
So how can you set the style of the Accelerator display text in a ContextMenu using CSS?
I inspected the skin and found out the accelerator-text class is assigned to the Label that displays the accelerator, which means you can use
.context-menu .accelerator-text {
-fx-text-fill: blue;
}
to style the Label displaying the accelerator.
I just gave a menuItem an id
fxml:
<MenuItem id="menuItem" mnemonicParsing="false" text="Close" accelerator="Shortcut+C"/>
and tried:
css:
#menuItem>Label {
-fx-background-color: #0093ff;
-fx-text-fill: #ffff00;
}
and it worked.
Hello i'm trying to change the color of an ImageView when your mouse is on it(hover)
So I have a css file that contains this:
.cross:hover {
-fx-background-color: red;
}
And this is cross:
#FXML
private ImageView cross;
I set the fx:id in the fxml file.
Now nothing happens when I hover over it.
This is how I add the style sheet to the scene:
scene.getStylesheets().add(getClass().getResource("Style.css").toExternalForm());
This is how I set the id for css on the ImageView:
cross.getStyleClass().add("cross");
So how would I change the color of the ImageView when I hover over it?
The color of an ImageView is defined by the pixel data in the image itself. You probably need to create (externally) an alternative image with the "background" changed to red, and then use the -fx-image CSS property of ImageView to change the image displayed:
.cross {
-fx-image: url(images/cross.png);
}
.cross:hover {
-fx-image: url(images/red-cross.png);
}
where the images folder has the same parent folder as the CSS file (see CSS docs on URL.)