Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Swing button invoke java mail API, program seems to be dead

843834Jul 17 2009 — edited Aug 3 2009
I'm confused by the Swing program. I add a button event to send mail, the code is below, in which use SpringMail API to send the mail.
but it doesn't work when I click the button and also the program seem to be dead. When I debug it, it stop at the line 'mailSender.send(msg);' and can not finish. The code is no problem if I put them in main() function and test it.
I Know the Swing has the eveet dispatch thread, is there any problem with threads? To be honest, I'm not familiar with Java Concurrency.
How can solve this problem?
pls help!
private void sendMailButtonActionPerformed(java.awt.event.ActionEvent evt) { 
        System.out.println("Sending Mail Start");
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
	mailSender.setHost(server.getHost());
	mailSender.setUsername(server.getUsername());
	mailSender.setPassword(server.getPassword());

	SimpleMailMessage msg = new SimpleMailMessage();
	msg.setFrom(mail.getFrom());
	msg.setTo(mail.getTo());
	msg.setSubject(mail.getSubject());
	msg.setText(mail.getContent());
	mailSender.send(msg);
        System.out.println("Sending Mail End");
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2009
Added on Jul 17 2009
1 comment
201 views