• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic