Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <code>ListSelectionListener</code> added to selection models that you can get with <a href="http://docs.oracle.com/javase/6/docs/api/javax/swing/JTable.html#getSelectionModel%28%29" rel="nofollow">getSelectionModel()</a>. </p> <p>Maintain the logic of presentation using table models. Once selection in <code>master</code> table changes update model/models of <code>details</code> tables accordingly. As a result of the data update, the model will notify its view (the table) about the changes. And view will refresh accordingly.</p> <p>Read more about models in <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html" rel="nofollow">How to Use Tables</a>. </p> <p><strong>EDIT:</strong> </p> <p>Since you load the data from database be sure to do it <em>not from</em> Event Dispatch Thread (EDT) to avoid performance issues. Look into <a href="http://docs.oracle.com/javase/6/docs/api/javax/swing/SwingWorker.html" rel="nofollow">SwingWorker</a> to perform lengthy operations on a dedicated thread. Read more about <a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/worker.html" rel="nofollow">Worker Threads and SwingWorker</a>.</p> <p><strong>EDIT: following code upload</strong></p> <p>It seems that you misinterpreting <code>SwingWorker</code> specs. <code>execute()</code> method is not blocking, it schedules worker execution and returns immediately. UI updates should be done in <code>process()</code> or <code>done()</code> methods, which are invoked by the worker on EDT. Below is a revised version of one of the of functions from the code you posted: </p> <pre><code>public void retrieveDetailTransaction(final String noTrans){ SwingWorker&lt;List&lt;TransactionDetail&gt;, Void&gt; worker = new SwingWorker&lt;List&lt;TransactionDetail&gt;, Void&gt;() { public List&lt;TransactionDetail&gt; doInBackground() { List&lt;TransactionDetail&gt; listTransD = transDetailControl.select(noTrans); return listTransD; } public void done() { try { listTransDetail = get(); transDetailModel.setListTransaction(listTransDetail); transactionDetailTable.setModel(transDetailModel); } catch (InterruptedException ex) { ex.printStackTrace(); } catch (ExecutionException ex) { ex.printStackTrace(); } } }; worker.execute(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload