Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ending SwingWorker after cancel

Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am doing a small mail program to allow a user to send an attachment from the main program.
I have created a method called send() in which all the necessary javamail methods are used to
provide data about the delivery such a SMTP host etc.

The send method is then used in SwingWorker because when the user clicks on the Button labelled send
the Button looks to freeze. The Button is responsive when the send method is used in the SwingWorker class
I have created. There is another Button to cancel and this is supposed to dispose of the JDialog.
If the send method returns false and the person cancels, the GUI does not dispose, because I see the
program is running in the area that notifies us of this in NetBeans. Even after the Exception in send is caught and I specify to dispose of the GUi it doesn't. The method is returning false because I am not connecting. So What? At least I now what will happen if the user cannot send the attachment. There must be some way of stopping that thread in the SwingWorker regardless of whether it returns true or false.

I am using the latest version of Java on a duo processor with 4 G of RAM. Although my Swing user interface is ultra fast and responsive, I need to kick it up a notch and make sure everything is as snappy as possible. I really do want to keep my send method in the SwingWorker.

At am at my wit's end over this one.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic