Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree column not formatting on first display  RSS feed

 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • 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
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!