I am currently trying to implement threading on a table. Unfortunately, this table does not show values concurrently when I am adding values by query to the table manually. Here's the event that I have performed:
private void formWindowOpened(java.awt.event.WindowEvent evt) {
Runnable hello = new orderRun(tableOrder); //sending the table to the class
Thread thread1 = new Thread(hello); //opening a thread
thread1.setDaemon(true);
thread1.start();
}
and here's a class that is dedicated for it.
public class orderRun implements Runnable {
JTable t;
public orderRun(JTable t){
this.t = t;
}
public void run(){
String[] col = {"Invoice", "Customer", "Item", "Quantity", "Date Purchased"};
DefaultTableModel tableModel = new DefaultTableModel(col, 0);
t.setModel(tableModel);
for (int i = 0; i < showOrders(LoginForm_CPOS.username).size(); i++)
{
tableModel.addRow(showOrders(LoginForm_CPOS.username).get(i).getItem().toArray());
}
}
}
Now, is there anyway for the values on the table that is caught from the database to be shown concurrently or simultaneously when I add values by queries?