Login in SwingWorker
===

I have a class which extends `SwingWorker<Void, Void>`. In it's background thread I was supposed to do login, if successful changing layout and adding new panels to frame. So Swing worker do following 3 tasks:

1. Login
2. Change layout
3. Add/remove panels.

So I wrote this function in doInBackground() method. But what happens here is this 3 methods are always executed, no matter login is successful or not. I want to stop executing worker if login fails. I tried cancel() method but it did not worked. How can I do this in proper way? *What could be the proper way to do login task in SwingWorker?*