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 8926927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:06:16+00:00 2026-06-15T08:06:16+00:00

I am trying to create a loading screen for my program so it will

  • 0

I am trying to create a loading screen for my program so it will display the loading screen while loading the main screen or while executing a particular task. I tried to use a JDialog as the loading screen but for some reason, once the loading screen dialog opens up, it doesnt let the main program run its own job. How do I make them work both at the same time?

Here is the code for my loading screen:

public class FrmLoading extends JDialog {

  private static FrmLoading loading;

  public FrmLoading(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    this.setLocationRelativeTo(null);
  }

  public static void startAnimation(){
    loading = new frmLoading(null, true);
    loading.setVisible(true);
  }

  public static void stopAnimation(){
    loading.dispose();
  }

  private void initComponents(){
    //build the Dialog
  }
}

this is how I use it:

private void login(){
    FrmLoading.startAnimation();
    //open main program
}

...

private void mainStart(){
    //load contents
    FrmLoading.stopAnimation();
}

I know that there is a loadingscreen default to java swing but I dont want to use it, I want the animation I made.

  • 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-15T08:06:17+00:00Added an answer on June 15, 2026 at 8:06 am

    Use SwingWorker

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
        @Override
        protected Void doInBackground() {
            //do your stuff in background
            return null;
        }
    
        @Override
        protected void done() {
            frmMain.setVisible(true);
            loading.dispose();
            disposeThis(); //a method that calls this.dispose();
        }
    };
    worker.execute();
    loading.setVisible(true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a custom binding that will show a loading gif while
I'm trying to create a splash screen that shows assemblies (all referenced library) loading
I don't want to display the bitmap on the screen. Just trying to create
I'm trying to create a custom loading/throbber icon for my app. I have an
I am trying to create a simple Twitter client with lazy loading of Twitter
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I'm trying to create a word count (for any page) bookmarklet without loading an
I'm trying to use CSS to create a 'greyed out' effect on my page
I'm to trying to create a class to deal with loading in resources (textures,
I have been trying to create a slide left effect to display my page

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.