For Programmers: Free Programming Magazines  


Home > Archive > Java Beans > March 2005 > Re: Right align cell values in JTable ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Right align cell values in JTable ?
John

2005-03-16, 3:58 am

The DefaultTableCellRenderer extends a JLabel I think, so every time a
cell needs to be redrawn the same object (JLabel) with a different
content is returned. You can change the alignment for the JLabel, the
problem is that all the cells will have the new alignment. The easiest
way is to write an extension to DefaultTableCellRenderer and use a
switch block for the column. Just change the alignment for the columns
you want. This is pretty easy and fast.

Ulf Meinhardt wrote:
> I would like to right align all values (not the headers) of column num 7 in a JTable.
> Do I really need to install a DefaultTableCellRenderer?
> I could imagine that there is a more easier solution similar to:
>
> myJTable.getColumnNum(7).setRightAligned()
>
> Ulf
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com