1

I cant seem to find a way of making the title bar of my window be RTL. I can make the inner nodes RTL by changing the node orientation property, but not the title bar. So I get a really weird looking app where everything is RTL except the title bar.

How can I fix this?

David Limkys
  • 4,907
  • 5
  • 26
  • 38
  • Create an [MCVE](http://stackoverflow.com/help/mcve) and log it in [a bug report](https://wiki.openjdk.java.net/display/OpenJFX/Submitting+a+Bug+Report) with your environment information. – jewelsea Oct 20 '14 at 17:45

2 Answers2

1

You need to invoke setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT) on the scene before showing the stage primaryStage.show():

enter image description here

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("Hello World");
        Scene scene = new Scene(root, 300, 275);
        primaryStage.setScene(scene);
        scene.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
        primaryStage.show();
    }


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

Because the orientation of children might be different for each child, the orientation of a child node when explicitly set can override the parent. For example, the top level window might be right-to-left, with the title and close box appearing on the left.

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
0

Just like what @Eng.Fouad said for scene object can be done for menubar. Invoking

setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT)

for the menubar object makes it rtl:

MenuBar menuBar = new MenuBar();
menuBar.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);

except that the arg for this method can be

NodeOrientation.LEFT_TORIGHT

which makes it left to right and

NodeOrientation.INHERIT

that gets its value from the parent container.

Armali
  • 18,255
  • 14
  • 57
  • 171
Reza
  • 845
  • 13
  • 18