Problem updating JTable

Discussion in 'Java' started by Jorge Castro, Jul 29, 2003.

  1. Jorge Castro

    Jorge Castro Guest

    Hi,

    I am having the following annoying problem with a JTable(MyTableModel).
    After constructing a MyTableModel extends AbstractTableModel, which gets its
    data from a remote (RMI) database,
    I add a new record to the database.

    At this point, upon reception of a notification event from the remote
    database triggered by the
    successfull addition of the new record, another object triggers execution of
    the fireTableRowsUpdated() method of the MyTableModel .

    The fireTableRowsUpdated() sends an event to its listeners, in this case the
    JTable, causing it to read the new data from
    the remote database, updating itself.

    This is the theory. What is happenning in practice is that:

    1) the fireTableRowsUpdated() is called correctly

    2) although I cannot verify that the JTable has received the above event, it
    appers to have done so because
    , in addition to being in the list of listeners of MyTableModel, I can
    verify that some of the methods of the
    AbstractTableModel get called (as they should) to updata the JTable.
    For example after the new record is added to the database, the getRowCount()
    and the getValueAt() are both called,
    and try to read data from the database.

    However, it appears that the getValueAt() method is not called enough times
    to fully update the JTable and the new record
    is not shown at all. Only when I mouse click on one of the cells are all
    records displayed including the new added recorded.

    Can anyone suggest the cause for this apparent problematic behaviour?
    Why does the JTable fail to redraw itself showing the new record, after the
    fireTableRowsUpdated() is called?

    Thanks a lot

    Jorge Castro
     
    Jorge Castro, Jul 29, 2003
    #1
    1. Advertising

  2. Jorge Castro

    Roedy Green Guest

    On Tue, 29 Jul 2003 20:16:19 +0100, "Jorge Castro"
    <> wrote or quoted :

    >I add a new record to the database.


    you do know you must do this on the SWING thread.


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jul 29, 2003
    #2
    1. Advertising

  3. "Jorge Castro" <> writes:
    > Can anyone suggest the cause for this apparent problematic behaviour?


    A very fare fetched guess would be to check your threading behavior.

    /Thomas
     
    Thomas Weidenfeller, Jul 30, 2003
    #3
  4. Jorge Castro

    Jorge Castro Guest

    Thanks for replying.

    I have a good feeling about your sugestion.


    My client GUI only uses one (main) thread (for the time being), so how do I
    fire the table change event on the Swing thread?

    Thanks





    Jorge Castro
    "Roedy Green" <> wrote in message
    news:...
    > On Tue, 29 Jul 2003 20:16:19 +0100, "Jorge Castro"
    > <> wrote or quoted :
    >
    > >I add a new record to the database.

    >
    > you do know you must do this on the SWING thread.
    >
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Jorge Castro, Jul 30, 2003
    #4
    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,549
    manusa
    Apr 12, 2007
  2. Bryan R. Meyer
    Replies:
    4
    Views:
    3,957
    Bryan R. Meyer
    Sep 6, 2004
  3. Tintin92
    Replies:
    1
    Views:
    1,813
    Andrew Thompson
    Feb 14, 2007
  4. news.rcn.com
    Replies:
    2
    Views:
    1,182
    Roedy Green
    Dec 10, 2007
  5. Haircuts Are Important
    Replies:
    3
    Views:
    414
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page