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
|
|
0
|
|
|
|
Reply
|
Jack
|
2/3/2004 3:15:50 AM |
|
"Jack" <Jackverbosity@verboseerrors.net> wrote in message
news:GnETb.26985$%72.24588@twister.nyroc.rr.com...
> 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
>
>
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;
}
}
|
|
0
|
|
|
|
Reply
|
Flo
|
2/3/2004 3:53:13 AM
|
|