Give the following code, one should expect the base color for the button to be yellow when the StackPane has styleclass = .pane.test and the mouse is over.
/* The border colors reflect what should be the colors for -fx-base with the inner color showing what the button's base color should be */
.pane {
-fx-base: black;
-fx-border-color: black, pink;
-fx-border-width: 6, 2;
-fx-border-insets: 5, 7;
}
.pane .button {
-fx-base: pink;
}
.pane.test {
-fx-base: grey;
-fx-border-color: grey, red;
}
.pane.test .button {
-fx-base: red;
}
.pane:hover {
-fx-base: orange;
-fx-border-color: orange, green;
}
.pane:hover .button{
-fx-base: green;
}
.pane.test:hover {
-fx-base: blue;
-fx-border-color: blue, yellow;
}
.pane.test:hover .button { -fx-base: yellow; }
/* this will spit out a warning which lets me know that this file was parsed. */
foo {}
import javafx.scene.control.Button;
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
String cssUrl = Main.class.getResource("test.css").toExternalForm();
boolean add = false;
private Parent getContent() {
final StackPane pane = new StackPane();
pane.getStyleClass().add("pane");
pane.setMinSize(100, 100);
pane.setPrefSize(100, 100);
Button button = new Button("button") {
@Override public void fire() {
if (add = !add) {
pane.getStyleClass().add("test");
} else {
pane.getStyleClass().remove("test");
}
}
};
pane.getChildren().add(button);
return pane;
}
public void start(Stage stage) {
stage.setX(100);
stage.setY(100);
stage.setWidth(300);
stage.setHeight(300);
final Scene scene = new Scene(getContent());
scene.getStylesheets().add(cssUrl);
stage.setScene(scene);
stage.setVisible(true);
}
}
/* The border colors reflect what should be the colors for -fx-base with the inner color showing what the button's base color should be */
.pane {
-fx-base: black;
-fx-border-color: black, pink;
-fx-border-width: 6, 2;
-fx-border-insets: 5, 7;
}
.pane .button {
-fx-base: pink;
}
.pane.test {
-fx-base: grey;
-fx-border-color: grey, red;
}
.pane.test .button {
-fx-base: red;
}
.pane:hover {
-fx-base: orange;
-fx-border-color: orange, green;
}
.pane:hover .button{
-fx-base: green;
}
.pane.test:hover {
-fx-base: blue;
-fx-border-color: blue, yellow;
}
.pane.test:hover .button { -fx-base: yellow; }
/* this will spit out a warning which lets me know that this file was parsed. */
foo {}
import javafx.scene.control.Button;
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
String cssUrl = Main.class.getResource("test.css").toExternalForm();
boolean add = false;
private Parent getContent() {
final StackPane pane = new StackPane();
pane.getStyleClass().add("pane");
pane.setMinSize(100, 100);
pane.setPrefSize(100, 100);
Button button = new Button("button") {
@Override public void fire() {
if (add = !add) {
pane.getStyleClass().add("test");
} else {
pane.getStyleClass().remove("test");
}
}
};
pane.getChildren().add(button);
return pane;
}
public void start(Stage stage) {
stage.setX(100);
stage.setY(100);
stage.setWidth(300);
stage.setHeight(300);
final Scene scene = new Scene(getContent());
scene.getStylesheets().add(cssUrl);
stage.setScene(scene);
stage.setVisible(true);
}
}