1

I want to sent a mail for multiple recipients after click the OK button and then show the in progress label in JFrame while sending a mail, but it shows a label after mail sent, how to solve it

JLabel title = new JLabel("In Progress");
title.setVisible(false);
title.setBounds(160, 50, 250, 40);
f.add(jb);
f.add(title);  
JButton b = new JButton("submit");  
b.setBounds(120,120, 80,30); 
f.add(b);
f.setSize(500,400);  
f.setLayout(null);
f.setVisible(true); 
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent  ae) {  
    if (!title.isVisible()) {
        title.setVisible(true);
    }
Properties props = new Properties();  
props.put("mail.smtp.host",host);  
props.put("mail.smtp.auth", "true");  

Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {  
    protected PasswordAuthentication getPasswordAuthentication() {  
        return new PasswordAuthentication(user,password);  
    }  
}); 
ArrayList<String> arr = new ArrayList<String>();
try (BufferedReader br = new BufferedReader(new FileReader("E:/selenium/mailid.csv"))) {
    String sCurrentLine;

    while ((sCurrentLine = br.readLine()) != null) {
        arr.add(sCurrentLine);
    }

} catch (IOException e) {
    e.printStackTrace();
} 
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Helena
  • 21
  • 4
  • 1
    search for swing worker something like this https://stackoverflow.com/q/17974940/5292302 – Petter Friberg Sep 22 '17 at 18:00
  • 1
    1) Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556) along with layout padding and borders for [white space](http://stackoverflow.com/a/17874718/418556). 2) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). 3) **A `JLabel` with no text is invisible. So leave it visible from the start and set the text on action.** – Andrew Thompson Sep 22 '17 at 20:13

0 Answers0