JavaFX标题栏RTL不受支持? [英] JavaFX title bar RTL not supported?
问题描述
我似乎找不到让我的窗口标题栏成为RTL的方法。
我可以通过更改节点方向属性而不是标题栏来使内部节点RTL。
所以我得到一个非常奇怪的应用程序,其中一切都是RTL,除了标题栏。
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?
推荐答案
你需要调用 setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT)
显示舞台前的场景 primaryStage.show()
:
You need to invoke setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT)
on the scene before showing the stage primaryStage.show()
:
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);
}
}
- 请参阅节点定位在JavaFX中:
- See Node Orientation in JavaFX:
因为每个孩子的孩子的方向可能不同,显式设置时子节点的方向可以覆盖父。例如,顶级窗口可能是从右到左,左侧出现标题和关闭框。
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.
这篇关于JavaFX标题栏RTL不受支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!