Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

align right in JTable  RSS feed

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Could you please tell me how to get the texts appear from the right (align right) of the column in a JTable.
Thanks in advance....
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set your own TableCellRenderer to the desired column in the table that extending DefaultTableCellRenderer and set alignment in getTableCellRendererComponent() method.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you be a little bit mroe specific.
Thank you
 
Jason Dobies
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a sample cell renderer that will right align the contents:

To apply this to the table, get the column you want to be right aligned and set the renderer to an instance of this object:

Hope that helps...
[ August 13, 2003: Message edited by: Jason Dobies ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!