Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Right Align numbers in Jtable

 
Smriti Anchu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set your own renderer (extending DefaultTableCellRenderer)
use the 'row' parameter of getTableCellRendererComponent() to setHorizontalAlignment(JLabel.RIGHT);
 
Smriti Anchu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 156
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic