Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem - cannot display rows correctly in jTable

Reply
Thread Tools

Problem - cannot display rows correctly in jTable

 
 
dtsignopoulos@gmail.com
Guest
Posts: n/a
 
      11-27-2006
There seems to be a problem with processing and inserting large (>2000)
amounts of data into jtable.

I read single rows from a database, do some processing and use
insertrow() to feed them to jtable. They get to be displayed (UI) as
soon ALL rows are done and over with, whereas the desired functionality
is to be displayed as soon as they are entered (row by row).

Need help as this is turning up to take too much time to figure out.
Have tried several approaches with no luck.

Some code is listed below:

// Create staff
DefaultTableModel model_matrix = new DefaultTableModel();
JScrollPane jScrollPane_matrix = new JScrollPane();
JTable jTable_matrix = new JTable(model_matrix) {
public boolean isCellEditable(int rowIndex, int vColIndex) {
return false;
}

// Add some columns
model_matrix.addColumn("Timestamp");
model_matrix.addColumn("hpic");

//Insert rows
while (more db rows...){
read row...
process row...
//insert row
i = model_matrix.getRowCount();
model_matrix.insertRow(i, new Object[] {timestamp, HPIC});
model_matrix.fireTableRowsInserted(i,i); setSelectedRow(i);

}

Need help, thanxs

 
Reply With Quote
 
 
 
 
Thomas Hawtin
Guest
Posts: n/a
 
      11-27-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
>
> I read single rows from a database, do some processing and use
> insertrow() to feed them to jtable. They get to be displayed (UI) as
> soon ALL rows are done and over with, whereas the desired functionality
> is to be displayed as soon as they are entered (row by row).


If you are running your database code in the Event Dispatch Thread (EDT)
then repaints (and the like) will not get a chance to run. If you run
your table update code outside of the EDT, then you will run into
trouble. Therefore, access the database in another thread and pass the
data over to the EDT. Use EventQueue.invokeLater - Google will probably
come up with more information.

> model_matrix.insertRow(i, new Object[] {timestamp, HPIC});
> model_matrix.fireTableRowsInserted(i,i); setSelectedRow(i);


DefaultTableModel.insertRow should fire the row insert event. Sending
two events imply that two rows were inserted.

Tom Hawtin
 
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
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
DataModel not showing correctly in JTable ebresie@usa.net Java 3 08-15-2005 01:23 AM
DataModel not showing correctly in JTable ebresie@usa.net Java 0 08-12-2005 09:40 PM
multiple validators on textfield w/display=dynamic don't display correctly cp ASP .Net Web Controls 3 12-24-2004 03:24 PM



Advertisments