Hi,
Would the CSS style set to a parent node be inherited to underlying nodes?
With below code, style setting to parent(VBox) is not getting inherited to children(Text).
Style.java
package style;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Style extends Application {
public static void main(String[] args) {
Application.launch(Style.class, args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");
Group root = new Group();
Scene scene = new Scene(root, 300, 250, Color.LIGHTGREEN);
scene.getStylesheets().add("/style/style1.css");
// Create children
Text text1 = new Text("Text1");
Text text2 = new Text("Text2");
// Create parent and set style
VBox vBox = new VBox();
vBox.getChildren().addAll(text1, text2);
vBox.getStyleClass().add("font-normal");
root.getChildren().add(vBox);
primaryStage.setScene(scene);
primaryStage.setVisible(true);
}
}
Style1.css
.font-normal {
-fx-font-size: 9pt;
-fx-font-family: "Arial";
-fx-fill: #FF0000;
}
Edited by: Simosh on Jun 10, 2011 4:24 PM