kaid
kaid

Reputation: 1249

Cannot edit table cell: Java Swing

I created a custom table using BeanTableModel as tableModel (not sure if this matters). The table populates data from an enum Object, and shoudl write to the object as well. Currently the behavior is that the table will populate the data correctly. If i write in a cell, I can. But when i tab, the cell is outlined in RED and i can only ESC, which returns the cell to normal with original data. I want to be able edit the table and save the data.

What are some possible fixes or points of problem?

Upvotes: 0

Views: 1008

Answers (2)

trashgod
trashgod

Reputation: 205875

the cell is outlined in red.

As illustrated here, this is the behavior of the default editor, JTable.GenericEditor. This suggests that your TableModel has an incorrect implementation of getColumnClass(), as others have suggested. Please edit your question to include an sscce, which may help isolate the problem.

Upvotes: 2

mKorbel
mKorbel

Reputation: 109823

CellEditor accepting inputed value that corresponding with Class.types, for example

  • in the case that Column Class is Number, then CellEditor accepting only Numbers, decimal separator and negative sign,

  • most complicated could be input correct value for plain Date Class

  • depends of Class.types and Formatters that are sets in your BeanTableModel

  • for better help sooner post an SSCCE

Upvotes: 3

Related Questions