2015-11-03 73 views
0

我有如下表 enter image description here對齊值的JTable細胞從右到左,而編輯

我發現This代碼在「كوردى」列對齊值從右到左。
它工作正常,但是當我編輯單元格對齊成爲從左到右,如上圖所示,
我在編輯時如何將值對齊到從右到左?

+0

changenthe默認的編輯器來支持你的要求 – MadProgrammer

+1

我不知道是否像[部份](http://stackoverflow.com/questions/354745/java-swing-gui-components-howto-rtl-view)會有所幫助,但我認爲區域設置aet這種東西up – MadProgrammer

+0

我發現它感謝看看答案... –

回答

0

我找到了我的答案,謝謝你對列的所有

JTextField textField = new JTextField(); 
textField.setBorder(new LineBorder(Color.BLACK)); 
DefaultCellEditor dce = new DefaultCellEditor(textField); 
table.getColumnModel().getColumn(2).setCellEditor(dce); 
textField.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 
+0

我認爲你設置組件全局使用['Component#applyComponentOrientation'](https://docs.oracle.com/javase/8/docs/api/java/awt/Component.html#applyComponentOrientation-java.awt.ComponentOrientation-)在頂層組件 – MadProgrammer

+0

但我在我的項目中有一些TextFields是左至Roght –