<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: How to make task monitor work</title>
	<atom:link href="http://khaledkhan.wordpress.com/2008/09/24/how-to-make-task-monitor-work/feed/" rel="self" type="application/rss+xml" />
	<link>http://khaledkhan.wordpress.com/2008/09/24/how-to-make-task-monitor-work/</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Mon, 17 Aug 2009 18:19:25 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: ckelloug</title>
		<link>http://khaledkhan.wordpress.com/2008/09/24/how-to-make-task-monitor-work/#comment-12</link>
		<dc:creator>ckelloug</dc:creator>
		<pubDate>Mon, 17 Aug 2009 18:19:25 +0000</pubDate>
		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=10#comment-12</guid>
		<description>Thanks for your helpful  post about using the netbeans provided TaskMonitor.  After playing with your code and reading the javadocs for task, taskmonitor, appframework, I finally determined that the following is the missing link for the many times I and others have asked this question about using a netbeans provided taskmonitor on the web:
 
To get a task to run with the TaskMonitor provided with the netbeans application template, you must create the task by extending org.jdesktop.application. An example task is shown below which just generates random numbers to increment the status bar.

public class OpenTask extends org.jdesktop.application.Task  {
   
    OpenTask(org.jdesktop.application.Application app) {
        super(app);
    }
    @Override
    public Void doInBackground() {
        Random random = new Random();
        int progress = 0;
        //Initialize progress property.
        setMessage(&quot;Opening the file&quot;);
        setProgress(0);
        while (progress &lt; 100) {
             
            //Sleep for up to one second.
            try {
                Thread.sleep(random.nextInt(1000));
            } catch (InterruptedException ignore) {
            }
            //Make random progress.
            progress += random.nextInt(10);
            setProgress(Math.min(progress, 100));

        }
        return null;
    }


The second thing that you need to do is create an action in the appnameView.java file to start the task.  The trick to getting the task monitor to work is to start the task through the TaskService as shown below.  Using the execute method on the task itself does not register it with the taskmonitor created by netbeans.  The fourth line below was my breakthough.

@Action
 public void OpenFile() {
        OpenTask foo= new OpenTask(MyApp.getApplication());       
        getApplication().getContext().getTaskService().execute(foo);     
    }</description>
		<content:encoded><![CDATA[<p>Thanks for your helpful  post about using the netbeans provided TaskMonitor.  After playing with your code and reading the javadocs for task, taskmonitor, appframework, I finally determined that the following is the missing link for the many times I and others have asked this question about using a netbeans provided taskmonitor on the web:</p>
<p>To get a task to run with the TaskMonitor provided with the netbeans application template, you must create the task by extending org.jdesktop.application. An example task is shown below which just generates random numbers to increment the status bar.</p>
<p>public class OpenTask extends org.jdesktop.application.Task  {</p>
<p>    OpenTask(org.jdesktop.application.Application app) {<br />
        super(app);<br />
    }<br />
    @Override<br />
    public Void doInBackground() {<br />
        Random random = new Random();<br />
        int progress = 0;<br />
        //Initialize progress property.<br />
        setMessage(&#8220;Opening the file&#8221;);<br />
        setProgress(0);<br />
        while (progress &lt; 100) {</p>
<p>            //Sleep for up to one second.<br />
            try {<br />
                Thread.sleep(random.nextInt(1000));<br />
            } catch (InterruptedException ignore) {<br />
            }<br />
            //Make random progress.<br />
            progress += random.nextInt(10);<br />
            setProgress(Math.min(progress, 100));</p>
<p>        }<br />
        return null;<br />
    }</p>
<p>The second thing that you need to do is create an action in the appnameView.java file to start the task.  The trick to getting the task monitor to work is to start the task through the TaskService as shown below.  Using the execute method on the task itself does not register it with the taskmonitor created by netbeans.  The fourth line below was my breakthough.</p>
<p>@Action<br />
 public void OpenFile() {<br />
        OpenTask foo= new OpenTask(MyApp.getApplication());<br />
        getApplication().getContext().getTaskService().execute(foo);<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ahmad</title>
		<link>http://khaledkhan.wordpress.com/2008/09/24/how-to-make-task-monitor-work/#comment-11</link>
		<dc:creator>Ahmad</dc:creator>
		<pubDate>Sat, 11 Apr 2009 16:52:18 +0000</pubDate>
		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=10#comment-11</guid>
		<description>thank you dear for this lesson..
but i want to ask you .what is the library or class that you use to run the sample above !!..simply i need to build an application which run a background tasks like running sql scripts which connected to oracle DB...etc..

hope you can help and advice me in this..

thank you alot .
(sorry for duplication , but i forgot to check notification comment via email)</description>
		<content:encoded><![CDATA[<p>thank you dear for this lesson..<br />
but i want to ask you .what is the library or class that you use to run the sample above !!..simply i need to build an application which run a background tasks like running sql scripts which connected to oracle DB&#8230;etc..</p>
<p>hope you can help and advice me in this..</p>
<p>thank you alot .<br />
(sorry for duplication , but i forgot to check notification comment via email)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ahmad</title>
		<link>http://khaledkhan.wordpress.com/2008/09/24/how-to-make-task-monitor-work/#comment-10</link>
		<dc:creator>Ahmad</dc:creator>
		<pubDate>Sat, 11 Apr 2009 16:50:50 +0000</pubDate>
		<guid isPermaLink="false">http://khaledkhan.wordpress.com/?p=10#comment-10</guid>
		<description>thank you dear for this lesson..
but i want to ask you .what is the library or class that you use to run the sample above !!..simply i need to build an application which run a background tasks like running sql scripts which connected to oracle DB...etc..

hope you can help and advice me in this..

thank you alot .</description>
		<content:encoded><![CDATA[<p>thank you dear for this lesson..<br />
but i want to ask you .what is the library or class that you use to run the sample above !!..simply i need to build an application which run a background tasks like running sql scripts which connected to oracle DB&#8230;etc..</p>
<p>hope you can help and advice me in this..</p>
<p>thank you alot .</p>
]]></content:encoded>
	</item>
</channel>
</rss>
