Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9219099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:01:30+00:00 2026-06-18T03:01:30+00:00

I am trying to display an loading animation(a gif file) while getting connected and

  • 0

I am trying to display an loading animation(a gif file) while getting connected and fetching all messages from gmail imap server using java ,but the animation is not visible …my code is as show below pls help me in this context if any solution exists….

import java.io.*;
import java.awt.*;
import javax.swing.*;
import javax.mail.*;
import java.awt.event.*;
import javax.mail.*;
import javax.mail.event.*;
import java.util.*;



public class vmail extends JFrame implements ActionListener,MouseMotionListener
{
    Container cp;
    JLabel background,loader;
    ImageIcon ic1,ic2;
    JTextField tuname,tpassword;
    JButton blogin;
    JPanel jp_login;

    public vmail()
    {
        setSize(900,640);
        setTitle("GMAIL CLIENT ");
        setLocation(200,50);

        cp=getContentPane();
        cp.setLayout(null);
        cp.setBackground(Color.white);


        String workingDir = System.getProperty("user.dir");
        workingDir=workingDir.substring(0,14);

        loader=new JLabel("");
        ic2=new ImageIcon(workingDir+"\\images\\progressbar1.gif");
        loader.setIcon(ic2);
        loader.setBounds(230,90,400,400);
        loader.setVisible(false);
        cp.add(loader); 



        jp_login=new JPanel();
        jp_login.setLayout(null);








        tuname=new JTextField(10);
        jp_login.add(tuname);
        tuname.setBounds(604,163,245,30);
        tuname.addMouseMotionListener(this);


        tpassword=new JTextField(10);
        jp_login.add(tpassword);
        tpassword.setBounds(604,224,245,30);
        tpassword.addMouseMotionListener(this);



        blogin=new JButton("");

        blogin.setBounds(605,271,53,29);
        blogin.setOpaque(false);
        blogin.setContentAreaFilled(false);
        blogin.setBorderPainted(false);
        blogin.addActionListener(this);
        blogin.addMouseMotionListener(this);
        jp_login.add(blogin);



        background=new JLabel("");

        System.out.println(workingDir);
        ic1=new ImageIcon(workingDir+"\\images\\background.png");
        background.setIcon(ic1);
        background.setBounds(0,0,900,600);

        jp_login.add(background);




        jp_login.setBounds(0,0,900,600);
        cp.add(jp_login);


        setVisible(true);
        setDefaultCloseOperation(3);
    }

    public static void main(String[] args) 
    {
        UIManager.LookAndFeelInfo info[];
        info=UIManager.getInstalledLookAndFeels();
        String name=info[3].getClassName();

        try
        {
            UIManager.setLookAndFeel(name);
        }  
        catch(Exception e)
        {
            System.out.println(e);
        }

        vmail v=new vmail();

    }

    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==blogin)
        {




            if(tuname.getText().equals("")||tpassword.getText().equals(""))
            {
                JOptionPane.showMessageDialog(this,"Incorrect Data Provided");
            }
            else
            {
                loader.setVisible(true);


                Properties props = System.getProperties();
                props.setProperty("mail.store.protocol", "imaps");
                try 
                {

                        Session session = Session.getDefaultInstance(props, null);
                        Store store = session.getStore("imaps");
                          try
                          {
                            store.connect("imap.gmail.com", tuname.getText(),tpassword.getText());
                            System.out.println("The Store connected is :  "+store);
                          }
                          catch(Exception e)
                          {
                            loader.setVisible(false);
                            JOptionPane.showMessageDialog(this,"Invalid User..");
                            System.out.println("Cannot connect error \n\n"+e);
                          }

                        vmail_in v=new vmail_in(store);
                        loader.setVisible(false);
                        this.setVisible(false);



                }
                catch(Exception e)
                {
                        loader.setVisible(false);
                    System.out.println("Setup Connection Error \n\n"+e);
                }
                loader.setVisible(false);   

            }
        }
    }


    public void mouseMoved(MouseEvent e) 
    {
                    if(e.getSource()==tuname)
                      tuname.setCursor(new Cursor(Cursor.HAND_CURSOR));
                    if(e.getSource()==tpassword)
                      tpassword.setCursor(new Cursor(Cursor.HAND_CURSOR)); 
                    if(e.getSource()==blogin)
                     blogin.setCursor(new Cursor(Cursor.HAND_CURSOR));      

    }

    public void mouseDragged(MouseEvent e) 
        {  }





}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:01:31+00:00Added an answer on June 18, 2026 at 3:01 am

    That’s because you attempting to establish a connection to your IMAP store within the context of the Event Dispatching Thread (aka EDT).

    One of the responsibilities of the EDT is to dispatch paint requests, so while your blowing it, it can’t respond to any repaint updates (or user input).

    You need to use some kind of background thread to execute the connection process, after starting your connection animation.

    I suggest you take a look at Concurrency in Swing and pay special attention to the SwingWorker section

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to display a loading gif before submitting a multipart-form (file upload), this
I'm trying to display a custom progressdialog while loading RSS feed from an HTTP
I am trying to display data that I am getting from server through json.
I am trying to display a loading message with an loading bar animation so
I'm trying to display an overlay that says page loading...please wait while data is
I need a little help, i'm trying how to make display AJAX loading.gif is
I'm trying to display an image (.gif) for page loading in html page until
I'm trying to display Japanese characters on a PHP page. No loading from the
I'm trying to display a loading icon while my iPhone app downloads a network
I am trying to display a Loading Image in a new JFrame when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.