How to create a task for using progress monitors in java?


I've created a stand alone java application in which i need to copy files from one place to other. But the copying takes times and i want to show the progress of the copying with the help of progress monitor in java. Progress Monitor requires a task as its parameter, but i do not know how to create a task for that copying function. Can anyone please give me some code or examples regarding creating a task.
-Thanks in advance

In order to create a task for a progress monitor first create a subclass of swingworker where you mention the code that is to be executed in the doInBackground() method. Then create an object of the class and execute it. For Progress Monitor add a propertyChangeListener to the class that calls the object and a changepropertyListener to that particular object for which you want to create the progress monitor. For more info check this link.