JAVA Swing GUI组件HOWTO RTL看法?
-
21-08-2019 - |
题
我怎样才能让我的Java Swing GUI组件[右至左]从NetBeans的桌面应用程序?
阿拉伯语解决方案
难道你只需要使用:
Component.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT )
我相信,Swing组件都已经对RTL的支持,没有他们?
不知道如何/在那里你会怎么做,在关于NetBeans中,虽然。
其他提示
的呼叫
Component.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT )
应达到目的。但一定要使用SwingConstants中领先,而是左,右的尾随你的布局。这同样适用于GridBagConstraints.LINE_START或LINE_END代替WEST或EAST,并且可能是一些类似的情况,我忘了提
您可以使用对齐,但如果你有你的嵌入文本中英文字母或数字,不会处理复杂问题。
这可能是优选使用某种样式的文本窗口小部件或甚至一个嵌入式HTML /富文本查看器的
我不认为标准的JLabel可以以其它方式处理的复杂性。
如果您有内内的contentPane面板上的组件,你可以使用它
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;
}
}
}
不隶属于 StackOverflow