Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable cell data alignment  RSS feed

 
seetha gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have created a table using a JTable. I want to align some columns data right, and some left and some columns center. How do I go about to do this. Can you please help me.
Thanks in advance
Seetha
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi seetha,
If u are using your own renderer and editors for those colums then in the overidden getTableCellRendererComponent()/getTableCellEditorComponent() method
you can write the following statements for those particular columns
setHorizontalAlignment(SwingConstants.RIGHT);
otherwise if u have not defined your own renderer/editor then u can try
table.getDefaultCellEditor(...).setHorizontalAlignment(SwingConstants.RIGHT);
table.getDefaultCellRenderer(...).setHorizontalAlignment(SwingConstants.RIGHT);
just check if it helps
regards
deeksha
note : Do verify method signatures before u compile your program





[This message has been edited by deekasha gunwant (edited February 13, 2001).]
 
seetha gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deeksha,
This did work , but I have one more problem, where if I have these editors, and try to disable the table, then these columns look enabled and all other columns data look disabled . Please do help me in solving this.
Thanks in advance
Seetha
 
Kannan Raman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Seetha
The Same problem i had, when i used deekasha advice the problem is solved. i am using renderer and editors also. but i wrote the deekasha code in getTableCellRendererComponent() , its working fine.I think u r using getTableCellEditorComponent() method.pls try renderer method. i hope the problem will be solved.
regards
Kannan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!