Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > Jtable live updating problem

Reply
Thread Tools

Jtable live updating problem

 
 
fishinastorm fishinastorm is offline
Junior Member
Join Date: Jun 2010
Posts: 1
 
      06-26-2010
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.
 
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
Updating JTable Atomically - block data changes while updating. news.rcn.com Java 2 12-10-2007 11:49 AM
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
Updating JTable Cells with Custom Renderer Bryan R. Meyer Java 4 09-06-2004 06:01 AM
Problem updating JTable Jorge Castro Java 3 07-30-2003 01:04 PM



Advertisments