• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting a cell editor for a single cell.  RSS feed

 
Stuart Chambers
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to change some code that deals with a JTable and the contents of each cell in the first column.

Each cell in the first column contains a combo-box and the contents of these combo-boxes is setup via setCellEditor.

The problem I have is that this process sets the contents for EVERY combo-box in that column all at once. I would like to set each combo-box individually.

At the moment each cell gets set to with options {"Add", "Ignore", "Replace"}, but in some instances it is not correct to have "Replace" as an option and I'd like these rows to have the options {"Add", "Ignore"}.

I am at a loss as at the moment. I can only set the contents of every cell and would love to know if there is a way to deal with each cell individually.

Thanks,
Stu...
 
Eric Snell
Greenhorn
Posts: 28
Java Mac MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A table cell editor has a method, getTableCellEditorComponent, that you can override. Populate your combo box before returning it from that method.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!