Hi everybody:
I use this code for adjust the alignment of the cells in JTable from left to right but I got nothing.
I don't know if there is something wrong in the code or I use a wrong way for do it...!!?
I hope you help me.
This is the code
public class RightTableCellRenderer extends DefaultTableCellRenderer{
public RightTableCellRenderer() {
setHorizontalAlignment(JLabel.RIGHT);
}
}
public class JoTable extends JTable {
public JoTable() {
setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
setTableCellAligment(JLabel.CENTER);
updateUI();
}
public void setTableCellAligment(int alignment) {
RightTableCellRenderer cellRenderer = new RightTableCellRenderer();
for (int i = 0; i < getColumnCount(); i++) {
this.setDefaultRenderer(getColumnClass(i), cellRenderer);
}
}
}
Then I use the JoTable in other class and fill it with data but the data still left alignment....?
Please help me
Thanks