2012-06-17 34 views
2

当我向JTable添加列时,默认情况下,它们从左到右排列。
例如如果我在这个顺序(从左至右)地址:从右向左排列JTable列

col1,col2,col3 

我会得到:

+------+------+------+ 
| col1 | Col2 | Col3 | 
+------+------+------+ 

但我想这一点:

+------+------+------+ 
| col3 | Col2 | Col1 | 
+------+------+------+ 

我怎样才能让一个JTable是安排从右到左的列?

+0

可以将它们放在表格中,或者显示在通常情况下文本从右到左运行的语言环境中。 –

回答

4

setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)或applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)会做的伎俩。 请参考Java文档为进一步澄清

setComponentOrientation

applyComponentOrientation

或者你可以扭转列名阵列和 行数据阵列的阵列。

2

我在JTable上设置了.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)

感谢