• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JTable cell data alignment

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic