Wednesday, December 3, 2014

JavaFX example of using scene.nodeOrientationProperty().setValue(NodeOrientation.RIGHT_TO_LEFT)



package javafxhello;

import javafx.application.Application;
import javafx.geometry.NodeOrientation;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class JavaFXHello extends Application {
    
    @Override
    public void start(Stage primaryStage) {

        HBox hBox123 = new HBox();
        hBox123.getChildren().addAll(
            new Label(" Label 1 "), 
            new Label(" Label 2 "),
            new Label(" Label 3 ")
        );
        
        HBox hBoxABC = new HBox();
        hBoxABC.getChildren().addAll(
            new Label(" Label A "), 
            new Label(" Label B "),
            new Label(" Label C ")
        );
        
        VBox vBox = new VBox();
        vBox.getChildren().addAll(hBox123, hBoxABC);
        
        Scene scene = new Scene(vBox, 300, 250);
        
        scene.nodeOrientationProperty().setValue(NodeOrientation.RIGHT_TO_LEFT);
        //hBox123.nodeOrientationProperty().setValue(NodeOrientation.RIGHT_TO_LEFT);
        //hBoxABC.nodeOrientationProperty().setValue(NodeOrientation.RIGHT_TO_LEFT);

        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
    
}

No comments:

Post a Comment