Different Cell Editors in same COLUMN of a JTable

Hi all,
  I'm trying to use JTable slightly unconventionally.
  In this case, the JTable is to be used to display only one record at a time, and therefore I'll only allow the user to make changes to one record at a time.
  A JTable with one row don't look very nice, so instead I'm made that row into a column. So right now I have 2 columns: the 1st column are the headers, while the 2nd are the editable values of the corresponding header (ie values column). If you have familiar with the object inspector in JBuilder or VB RAD environment, you'll know what I mean.
  Now I'm trying to make my cell editor for my values column to change according to the row that was selected.
Therefore, for example, if the user selects the "Name" row, I'll display a ordinary jtextfield cell editor, while in the "Nationality" row, I'll display a jcombobox cell editor.

  The problem for me arises when I try to switch from a jcombobox row to a jtextfield row. I used the listselectionmodel to detect a change in the row selection, and then switch the cell editor in the event handler. But it doesn't work, my jcombobox appears in the jtextfield row, carrying the jcombobx values there and overwriting it. Apparently, that was done even before my event handler was executed.

Is there a way around this?
Who is Participating?
vivexpConnect With a Mentor Commented:

Visit http://www2.gol.com/users/tame/swing/examples/JTableExamples2.html
the examples here might solve ur problem, If i have understood it correctly!!

Best of Luck
jernhungAuthor Commented:

That was a great site!

I didn't know JTable was that powerful!

Thanks for your help. That site will go into my bookmark.

A bonus 25 points!
All Courses

From novice to tech pro — start learning today.