Hi
I have a JTable with a custom TableModel which I want to allow the user to
be able to right-click row, select Edit, and have a set column (i.e. only
column 2 will become editable, set within the program) for that selected row
become editable.
What would be a good approach to do this?
The TableModel is given a list of domain objects (Bank Transactions) and
provides the JTable with the parts of the Bank Transactions needed to be
displayed. An isEditable attribute does not belong on the Bank Transaction
objects ... do I need to maintain a Model and View list within the
TableModel for which the View list objects may wrap the Model objects and
provide view-related attributes like isEditable ???
Thanks
Shane

Signature
Today I want to do something better than when I did it yesterday
Babu Kalakrishnan - 04 Aug 2004 15:23 GMT
> Hi
>
[quoted text clipped - 11 lines]
> TableModel for which the View list objects may wrap the Model objects and
> provide view-related attributes like isEditable ???
You could override the isCellEditable(row,col) method of the JTable and return
true to only the appropriate combination. Just remember that the column number
that is passed to you in this call is that of the View - not the model. So you
would need to call convertColumnIndexToModel(column) in case your JTable allows
the user to reorder columns by dragging on the header.
BK