Search code examples
javajtablealignment

Align values in JTable cells to right-to-left while Editing


I have the following table enter image description here

I found This code to align values in "كوردى" column to Right-To-Left.
It works fine, But when i edit cells the align becomes Left-To-Right as shown at the above Image,
What i do to align values to Right-To-Left while editing ?


Solution

  • I found the my answer, Thanks for all

     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);