Tomáš Hubálek Blog: Bavte se přiměřeně
Reklama
Reklama
Článek
How to execute long running tasks in NetBeans platform...
We work on J2EE project based on NetBeans platform and we solve typical tasks. My first problem was execution of long running tasks.
Here is a solution:
private void jbExecuteActionPerformed(java.awt.event.ActionEvent evt) {
// start thread
RequestProcessor.getDefault().post(new Runnable() {
public void run() {
ProgressHandle progress =
ProgressHandleFactory.createHandle("Loading data...");
progress.start(10);
try {
for (int i = 1; i < 10; i++) {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) { }
progress.progress(i);
}
} finally {
progress.finish();
}
}
});
}
The trick is in RequestProcessor.getDefault().post(new Runnable(){...}).
Inside new Runnable(){...} you may optionally use NetBeans Progress API
Odkazy na článek
Reklama
Komentáře:
Pokud chcete, můžete použít tyto pseudo tagy:
- [a href=http://url.com]link title[/a] bude převedeno na link.
- [abbr title=text]abbr[/abbr] bude převedeno na <abbr>.
- stejně tak i[cite], [code], [em], [strong], [q], [li] —
Přidejte komentář:
Komentáře jsou schvalovány před publikováním / Comments must be approved before being published. Thank you!

21:01:05 - Úterý, 30.01.07 -

