Custom JTable update problem

Discussion in 'Java' started by Seref Arikan, Jan 26, 2004.

  1. Seref Arikan

    Seref Arikan Guest

    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
    Seref Arikan, Jan 26, 2004
    #1
    1. Advertising

  2. Seref Arikan <> 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.
    Christian Kaufhold, Jan 26, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tivo Escobar
    Replies:
    1
    Views:
    7,317
    manusa
    Apr 12, 2007
  2. pat270881

    update JTable

    pat270881, Apr 5, 2005, in forum: Java
    Replies:
    3
    Views:
    15,039
    John McGrath
    Apr 6, 2005
  3. Tintin92
    Replies:
    1
    Views:
    1,703
    Andrew Thompson
    Feb 14, 2007
  4. Daniele Futtorovic

    Re: update JTable

    Daniele Futtorovic, Jul 17, 2008, in forum: Java
    Replies:
    0
    Views:
    479
    Daniele Futtorovic
    Jul 17, 2008
  5. Haircuts Are Important
    Replies:
    3
    Views:
    320
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page