• 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:

different aligment in jtable

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys
I have a jtable that I want some columns have right aligment and some of them have center. When I use this code:

All of my columns get CENTER aligment!
What's the problem?
regards
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
corrected source:Explanation: tb.setDefaultRenderer(tb.getColumnClass(0),renderer_right); sets renderer for specified column class (not column index!) You only take column class from column 0, next in for-loop class is tb.getColumnClass(i) but all column classes are the same so the same renderer will be used everywhere. Check what will happen when You put tb.setDefaultRenderer(tb.getColumnClass(0),renderer_right); after for-loop.>
 
pariya shiri
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bartek Myszkowski wrote:corrected source:Explanation: tb.setDefaultRenderer(tb.getColumnClass(0),renderer_right); sets renderer for specified column class (not column index!) You only take column class from column 0, next in for-loop class is tb.getColumnClass(i) but all column classes are the same so the same renderer will be used everywhere. Check what will happen when You put tb.setDefaultRenderer(tb.getColumnClass(0),renderer_right); after for-loop.>




Wow! It's works. thanks a million:thumbup:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic