Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As suggested <a href="https://stackoverflow.com/a/3072979/230513">here</a>, patterns such as <em>model-view-controller</em> and <em>observer</em> represent recurring design elements. A simple <a href="https://stackoverflow.com/a/2687871/230513">outline</a> may illustrate the interaction of classes, but a general solution is beyond the scope of StackOverflow.</p> <p>Still, it may be useful to look at how the principles might be applied. Suppose you are following the <a href="http://docs.oracle.com/javase/tutorial/essential/io/notification.html" rel="nofollow noreferrer">tutorial</a> and have implemented a <code>WatchService</code> in a <code>SwingWorker</code>, as shown <a href="https://stackoverflow.com/q/7784909/230513">here</a>. Now, suppose you want the main view, a <code>JTable</code>, to update itself in response to an arriving <code>WatchEvent</code>. You would arrange for the corresponding <code>TableModel</code> to register itself with the worker as a <code>PropertyChangeListener</code>, shown <a href="https://stackoverflow.com/q/7784909/230513">here</a> and <a href="https://stackoverflow.com/a/4637725/230513">here</a>. When the <code>PropertyChangeEvent</code> arrives, you update the <code>TableModel</code> and fire the appropriate event to update the <code>JTable</code>. The known <code>TableModel</code> implementations already include the required methods.</p> <p>A similar approach would be used to update the table in response to data arriving from the web.</p> <p>For settings, consider <code>java.util.Preferences</code>, mentioned <a href="https://stackoverflow.com/a/9481515/230513">here</a>, or <code>javax.jnlp.BasicService</code>, discussed <a href="https://stackoverflow.com/a/6886694/230513">here</a>.</p>
 

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