Custom JTable update problem

S

Seref Arikan

Hi,
I am using a custom table model, to keep a vector of a custom class,
and everything works fine. I have custom renderers and editors for my
types
The problem is, when a cell is in editing mode , displaying my custom
control ( which is a jtextfield actually )with a new typed value in
it , the user can click another button on the form, to add a new row
to table. The user will assume that the editing is complete and a new
row will be added, which is perfectly normal.
But when this happens, sometimes the value in the textbox gets lost,
and the new row is added. Somehow, the value in textbox in edit mode,
can't be written to the custom table model i am using.
The add new row button adds a new element into the vector in custom
table model instance, and calls fireTableDataChanged(). somehow the
new value in textbox can't be written to the corresponding field in
table model. I believe there is something i am missing, since this
should be a pretty common scenario.Any recommendations would be great.
Best Regards
 
C

Christian Kaufhold

Seref Arikan said:
The problem is, when a cell is in editing mode , displaying my custom
control ( which is a jtextfield actually )with a new typed value in
it , the user can click another button on the form, to add a new row
to table. The user will assume that the editing is complete and a new
row will be added, which is perfectly normal.
But when this happens, sometimes the value in the textbox gets lost,
and the new row is added. Somehow, the value in textbox in edit mode,
can't be written to the custom table model i am using.
The add new row button adds a new element into the vector in custom
table model instance, and calls fireTableDataChanged(). somehow the
new value in textbox can't be written to the corresponding field in
table model. I believe there is something i am missing, since this
should be a pretty common scenario.Any recommendations would be great.


If you call fireTableDataChanged, editing *must* be cancelled.

Use fireTableRowsInserted so that the cell that is being edited
remains.



Christian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top