Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java:将默认的Swing方向更改为RTL_Java_Swing_Orientation_Right To Left - Fatal编程技术网

Java:将默认的Swing方向更改为RTL

Java:将默认的Swing方向更改为RTL,java,swing,orientation,right-to-left,Java,Swing,Orientation,Right To Left,如何将swing的默认方向更改为RTL? 我的应用程序的所有组件都必须是RTL,我需要将默认方向更改为RTL 我知道我们可以通过以下方式更改组件方向: Component.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 但如果我这样做,我必须改变所有按钮,文本字段的方向。。。逐一地。 我的问题只是如何更改swing的默认方向(可能通过使用UIDefaults) 如果我不能做到这一点,请说最好的方式来实施这样的项目。(所有

如何将swing的默认方向更改为RTL? 我的应用程序的所有组件都必须是RTL,我需要将默认方向更改为RTL

我知道我们可以通过以下方式更改组件方向:

Component.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
但如果我这样做,我必须改变所有按钮,文本字段的方向。。。逐一地。 我的问题只是如何更改swing的默认方向(可能通过使用UIDefaults)

如果我不能做到这一点,请说最好的方式来实施这样的项目。(所有组件必须为RTL)


例如,我们可以在这里看到在swing中更改默认字体的解决方案:

我正在寻找相同的定位解决方案。

您可以使用它:

Component[] component = contentPane.getComponents();
    for(int i=0; i<component.length; i++){
        component[i].applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        Component[] cp = ((Container) component[i]).getComponents();
        for(int j=0; j<cp.length; j++){
            try{
                ((Component) ((JComboBox) cp[j]).getRenderer()).applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
            }catch(Exception e){
                continue;

            }
        }
    }
Component[]Component=contentPane.getComponents();
对于(int i=0;i