Event dispatching thread: Difference between revisions

Content deleted Content added
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 57:
 
====Samples====
<sourcesyntaxhighlight lang="java">
SwingWorker<Document, Void> worker = new SwingWorker<Document, Void>() {
public Document doInBackground() throws IOException {
Line 73:
};
worker.execute();
</syntaxhighlight>
</source>
 
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:
 
<sourcesyntaxhighlight lang="groovy">
doOutside {
def doc = loadXML() // heavy task
edt { display(doc) }
}
</syntaxhighlight>
</source>
 
====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.
 
<sourcesyntaxhighlight lang="java">
button.addActionListener(new ActionListener()
{
Line 122:
}
});
</syntaxhighlight>
</source>
 
Since Java 1.7, Java provides '''standard''' solution for custom '''secondary message loops''' by exposing ''createSecondaryLoop''() in system ''EventQueue''().