2 Replies Latest reply on Dec 26, 2012 3:37 PM by Kishori Sharan

    Inheriting -fx-text-alignment CSS Property

    Kishori Sharan

      I am referring to the Inheritance section in the following document:

      The document states that the three CSS properties are inherited by a node from its parent, by default:

      The following program is to demonstrate the above CSS rule.
      package test;
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.VBox;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;
      public class Test extends Application {
           public static void main(String[] args) {
           public void start(Stage stage) {
                VBox root = new VBox();
                root.setStyle("-fx-cursor: hand;" + 
                              "-fx-text-alignment: right;" + 
                              "-fx-font: normal bold 20px \"serif\"");
                Label lb2 = new Label("Just adding a long text to test the text alignment:");
                //lb2.setStyle("-fx-text-alignment: inherit");
                Text t2 = new Text("This is a big text for the Text node");
               //t2.setStyle("-fx-text-alignment: inherit");
                root.getChildren().addAll(lb2, t2);
                Scene scene = new Scene(root);
      I have the following questions:
      1. The -fx-text-alignment property is not inherited by default by the Label and Text nodes. If I specify the value as inherit, it works as expected.
      2. The textAlignment property is not just defined in the Text class. It is also defined in the Labeled class. The font property is not defined in the Font class either. Why does this document refer to these classes in the table in the Inheritance section?
      3. Can someone give me an example of what does this document mean by stating that -fx-text-alignment property is inherited by nodes from their parents, by default.