Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Custom JTable update problem

Reply
Thread Tools

Custom JTable update problem

 
 
Seref Arikan
Guest
Posts: n/a
 
      01-26-2004
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
 
Reply With Quote
 
 
 
 
Christian Kaufhold
Guest
Posts: n/a
 
      01-26-2004
Seref Arikan <(E-Mail Removed)> wrote:

> 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
--
And in short, I was afraid.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JTable, custom components and event handling Rajarshi Guha Java 5 06-22-2010 04:11 PM
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
How to move data from a CSV file to a JTable, and from a JTable to a CSV file ? Tintin92 Java 1 02-14-2007 06:51 PM
[JTable] Alignment in custom cell renderer Branko Kaucic Java 4 09-13-2005 07:03 AM
Updating JTable Cells with Custom Renderer Bryan R. Meyer Java 4 09-06-2004 06:01 AM



Advertisments