aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Right Align numbers in Jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Right Align numbers in Jtable" Watch "Right Align numbers in Jtable" New topic
Author

Right Align numbers in Jtable

Smriti Anchu
Ranch Hand

Joined: Dec 21, 2004
Posts: 40
Hi,

I have a JTable. I want to right align only one column that too from second row in the table. How do i do it

Do tell me as early as possible

regards
smriti
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
set your own renderer (extending DefaultTableCellRenderer)
use the 'row' parameter of getTableCellRendererComponent() to setHorizontalAlignment(JLabel.RIGHT);
Smriti Anchu
Ranch Hand

Joined: Dec 21, 2004
Posts: 40
Hi,

I am new to Swings. I wanna know what is a renderer, why is it needed. Could you please send me the code for the same.


thanks in advance
smriti
Anand Karia
Ranch Hand

Joined: Sep 25, 2004
Posts: 156

In simple language, you convert table column to your own created name and then change the default property to your required properties or etc.


Smriti, I hope this would help you out.




Love is GOD and GOD is Love.
Anand Karia
IT Concretor.......
M/s. Anand Karia Concreting IT
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if you're new to swing, read this first - before asking for people to provide
code for you.

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Right Align numbers in Jtable