Probably a FAQ... but here goes...
How do I force all JTable column entries to be right aligned or center
aligned? It appears the default is left aligned.
Thanks,
Jack
> Probably a FAQ... but here goes...
>
[quoted text clipped - 4 lines]
>
> Jack
Jack,
I beleive you will need to implement your own table model. The Java tutorial
at http://java.sun.com/docs/books/tutorial/uiswing/components/table.html is
what I read through to get around a similar problem. I created my own table
model and used a custom renderer.
class MyJLabelRenderer extends JLabel implements TableCellRenderer {
// constructor
MyJLabelRenderer() {
this.setHorizontalAlignment(CENTER);
}
// returns component to use as renderer
public Component getTableCellRendererComponent(JTable table, Object
value, boolean isSelected, boolean hasFocus, int row, int col) {
// could have some other logic in here...
return this;
}
}