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

different aligment in jtable  RSS feed

 
pariya shiri
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
 
Bartek Myszkowski
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!