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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:57:27+00:00 2026-06-16T04:57:27+00:00

I was building a small test tool with Java Swing using Netbeans IDE. I

  • 0

I was building a small test tool with Java Swing using Netbeans IDE.

I am trying to update a label, which is somehow not getting ‘repainted’/’refreshed’. I looked into a couple of similar questions on SO but was not able to resolve my problem.

private void excelFileChooserActionPerformed(java.awt.event.ActionEvent evt)
{
    if(!JFileChooser.CANCEL_SELECTION.equals(evt.getActionCommand()))
    {
        String selectedFile = excelFileChooser.getSelectedFile().getAbsolutePath();
        loaderLabel.setText("Please Wait..");
        try {
            //This is sort of a blocking call, i.e. DB calls will be made (in the same thread. It takes about 2-3 seconds)
            processFile(selectedFile);
            loaderLabel.setText("Done..");
            missingTransactionsPanel.setVisible(true);
        }
        catch(Exception e) {
            System.out.println(e.getMessage());
            loaderLabel.setText("Failed..");
        }
    }
}

loaderLabel is a JLabel and the layout used is AbsoluteLayout.

So, my problem is “Please Wait…” is never shown. Although call to the method processFile takes about 2-3 seconds, “Please Wait…” is never shown. However, “Done…”/”Failed…” are shown.

If I add a popup (JOptionPane) before the call to processFile, “Please Wait..” is shown. I am not able to clearly understand why this is happening.

Is there a “good practice” that I should follow before a heavy method call? Do I need to call an explicit repaint/refresh/revalidate?

  • 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-16T04:57:28+00:00Added an answer on June 16, 2026 at 4:57 am

    You need to call

     processFile(selectedFile);
    

    in another thread (not in the AWT thread). To do so you can do something like this :

    Thread t = new Thread(){
       public void run(){
           processFile(selectedFile);
           // now you need to refresh the UI... it must be done in the UI thread
           // to do so use "SwingUtilities.invokeLater"
           SwingUtilities.invokeLater(new Runnable(){
              public void run(){
                  loaderLabel.setText("Done..");
                  missingTransactionsPanel.setVisible(true);
              }
              }
           )
       }
    };
    t.start();
    

    Please not that I didn’t work with swing for a long time, so there may be some syntax issues with this code.

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

Sidebar

Related Questions

I'm building this small java applet in which I need a JPanel which will
I'm building a small java program to test all the document related features i
I'm building a small Java library which has to match units in strings. For
I'm building a small GUI-Test automation tool in C# for a application. One of
I am building a small applet in java. It works fine (really!) when I
I am building a small facebook app. Trying to search for values in an
I'm new to rails and building a small test app on rails3 (beta4). I
I am building some test application with Neo4j. I want to model small social
So, i'm building a small application using Rails. I need to use XMPP proto
i just started building a small test app to help me learn MVC. i

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.