• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable - single column header won't change from "A"  RSS feed

 
Kurt Peters
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried numerous ways of changing the column header for the single column in a JTable. The following code WORKS in a simple example app I made, but doesn't work in my "real app". Is there something that could be "blocking" changing the column header assignment? I use a "new" DefaultEditor" or "Default renderer" but I don't mess with any headers in them?


Renderer code:
 
Kurt Peters
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pretty interesting, but I noticed from the source code that if columnIdentifiers is not initialized then it outputs super.getColumnName(index).

So, I modified my tableModel to intiate the columnIdentifiers:


That seems to allow me to get rid of the A, but I still can't dynamically change the column headers from the initial value. :-(
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I've tried numerous ways of changing the column header for the single column in a JTable.

don't know what you're trying to do with all that (didn't read most of it),
but this works OK for me (even when columns are dragged to a new pos)

 
Kurt Peters
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found that the number of columns wasn't being initialized -- (I returned "1") in the "getColumnCount()" of the TableModel, but that isn't the only thing that needed to be done. "setColumnCount()" had to be called to initialize the right variables, allowing storage of the values.
Kurt
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!