Jtable live updating problem

Discussion in 'Software' started by fishinastorm, Jun 26, 2010.

  1. fishinastorm

    fishinastorm

    Joined:
    Jun 26, 2010
    Messages:
    1
    Hi all, I'm trying to display a jtable in a pop up Jframe and am running into some problems. What i'am trying to do is as follows:

    catch a button action event in the main frame and display a pop up frame with a jtable populated with some data. The problem i have is that the jtable is populated with metadata i receive from a website and if i'm receiving many records, then the jtable is not displayed until all the records(metadata) is received from the website. I would like to change it such that as soon as the button event is detected in the main frame, I display the pop up frame along with the jtable and insert/update rows "as and when i receive the data from the website". In another words, i want to display the table and have the records appearing one at a time rather than displaying the jtable only after i receive all records.Below is how i'm trying to do it (but in vain :( ):

    .........
    Code:
    //add the table to the popup frame when application is started, but don't display the frame `until button action is //detected`
    extraInfoFrame.add(tblMetadata);
    extraInfoFrame.setVisible(false);
    
    //handle code for button press; display the popup
    private void butMetadataActionPerformed(java.awt.event.ActionEvent evt) { 
        extraInfoFrame.pack();
        extraInfoFrame.toFront();
        //frame.setSize(350, 250);
        extraInfoFrame.setVisible(true);
    
    //retrieve rows data for the table
    for(int i=0;i<len;i++){
    Object[] data=new Object[4];data=getMetadata();
    //get model and insert row
    ((javax.swing.table.DefaultTableModel)tblMetadata.getModel()).insertRow(i,data);
    
    //tried something to notify the view abt change in table data 
    ((javax.swing.table.DefaultTableModel)tblMetadata.getModel()).fireTableRowsInserted(0, 0);
    tblMetadata.revalidate();
    tblMetadata.repaint();
    }
    }
    Have been racking my head to try and figure something out. A sample example would be greatly appreciated.
     
    fishinastorm, Jun 26, 2010
    #1
    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. Thomas Bell
    Replies:
    2
    Views:
    1,971
    Thomas Bell
    Nov 19, 2003
  2. alniyas

    Updaing database from JTable

    alniyas, Sep 13, 2007, in forum: Software
    Replies:
    0
    Views:
    989
    alniyas
    Sep 13, 2007
  3. =?Utf-8?B?Q2FybG9z?=

    RE: Updating Live Messenger 8.5

    =?Utf-8?B?Q2FybG9z?=, Oct 23, 2007, in forum: Windows 64bit
    Replies:
    0
    Views:
    458
    =?Utf-8?B?Q2FybG9z?=
    Oct 23, 2007
  4. mjs

    Updating Live Messenger 8.5

    mjs, Oct 23, 2007, in forum: Windows 64bit
    Replies:
    1
    Views:
    456
    =?Utf-8?B?Q2FybG9z?=
    Oct 23, 2007
  5. sonaljain

    Want Help in JTable

    sonaljain, Mar 8, 2011, in forum: General Computer Support
    Replies:
    0
    Views:
    990
    sonaljain
    Mar 8, 2011
Loading...

Share This Page