Content deleted Content added
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags |
|||
Line 57:
====Samples====
<
SwingWorker<Document, Void> worker = new SwingWorker<Document, Void>() {
public Document doInBackground() throws IOException {
Line 73:
};
worker.execute();
</syntaxhighlight>
If you use [[Groovy (programming language)|Groovy]] and <code>groovy.swing.SwingBuilder</code>, you can use <code>doLater()</code>, <code>doOutside()</code>, and <code>edt()</code>. Then you can write it more simply like this:
<
doOutside {
def doc = loadXML() // heavy task
edt { display(doc) }
}
</syntaxhighlight>
====Equivalents====
Line 96:
The open source '''[http://foxtrot.sourceforge.net/docs/worker.php Foxtrot]''' project emulates the Swing message loop pumping to provide the "synchronous" execution mechanism for arbitrary user tasks, which proceeds only after the worker completes the task.
<
button.addActionListener(new ActionListener()
{
Line 122:
}
});
</syntaxhighlight>
Since Java 1.7, Java provides '''standard''' solution for custom '''secondary message loops''' by exposing ''createSecondaryLoop''() in system ''EventQueue''().
|