• 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

JTree column not formatting on first display

 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I add a column to a JTable; I extended TableColumnModel to hold data on each possible column, and give the user a menu from which he can choose which columns to display. One of them is a column of type Integer, and it is not displayed by default. When I add it, it is added to the table and put in the right place (through JTable.addColumn() and JTable.moveColumn()), but the numbers are all left-justified. When I move the column manually, it corrects itself (to right-justified, for integers). If I then hide and redisplay the column it displays correctly.

I have another integer column that is displayed correctly; it appears by default instead of having to be added.

So I figure my add code is supposed to be doing something to it after it's added so that it displays correctly. Does anyone have any idea what that might be?

rc
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds to me like the table thinks it is displaying String or Object data so it uses the default renderer.

A table chooses the appropriate renderer based on the value returned from the getColumnClass() method. Or you can set the renderer to be used in the TableColumn itself.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic