编辑时将 JTable 单元格中的值从右到左对齐
Align values in JTable cells to right-to-left while Editing
我有以下table
我找到了 This 代码,用于将“كوردى”列中的值从右到左对齐。
它工作正常,但是当我编辑单元格时,对齐变为从左到右,如上图所示,
我如何在编辑时将值从右到左对齐?
我找到了我的答案,谢谢大家
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);
我有以下table
我找到了 This 代码,用于将“كوردى”列中的值从右到左对齐。
它工作正常,但是当我编辑单元格时,对齐变为从左到右,如上图所示,
我如何在编辑时将值从右到左对齐?
我找到了我的答案,谢谢大家
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);