I encountered the following issue using JavaFX.
Redefinition of tooltip style using stylesheet works in Java Scene Builder.
Redefinition of tooltip style at execution in eclipse with the same stylesheet included in FXML file generated from scene builder with
<stylesheets>
<URL value="@../style/myCSS.css" />
</stylesheets>
does not work (any other property redefinition works).
Redefinition of tooltip style at execution in eclipse with same stylesheet using code instruction :
scene.getStylesheets().add(this.getClass().getResource("/style/myCSS.css").toExternalForm());
works properly.
Stylesheet used (myCSS.css):
.tooltip {
-fx-background-radius: 2 2 2 2;
-fx-background-color: linear-gradient(#FFFFFF, #DEDEDE);
}
.page-corner {
-fx-shape: " ";
}
AnchorPane {
-fx-background-color: firebrick;
}
FXML file used:
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="91.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml">
<children>
<Button layoutX="72.0" layoutY="35.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Button">
<tooltip>
<Tooltip text="Tootip Text" />
</tooltip>
</Button>
</children>
<stylesheets>
<URL value="@../style/myCSS.css" />
</stylesheets>
</AnchorPane>
Edit: In other words I want to be abe to declare my stylesheet in the FXML file. Doing so seems to work for any property redefinition (AnchorPane background color in this case) except tooltips.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…