I was reading through multiple posts and I wasn't able to find a clear answer to my question.
I have an application (Main Frame) that has a start and a stop button and just a jTextArea. When a user presses the "start" button, a SwingWorker class is instantiated and runs (execute()) a task. That task is to connect to a database and do some checks. For every check, it updates the jTextArea correctly and everything is fine. When the stop button is pressed, i set the isCancelled() to true and thus the background process stops (I have the appropriate checks inside the SwingWorker to stop execution etc).
What I want to do is when the user presses "Start", the SwingWorker starts execution, sleeps for a few minutes and then re-runs the same task. When the "Stop" button is pressed, everything stops.
How can I achieve that? I understand that a SwingWorker background process is supposed to be run once. What would other ways of doing this be? Note that the reason I picked a SwingWorker was because I wanted to update the jTextArea while the background process runs.
Thank you in advance.