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

  • Home
  • SEARCH
  • 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 3872408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:55:21+00:00 2026-05-19T21:55:21+00:00

So I have a desktop application designed using the MVC pattern inspired by this

  • 0

So I have a desktop application designed using the MVC pattern inspired by this tutorial (but slightly modified). What this application needs to do is to copy a list of file from a directory to another. What I would like to do is basically update my GUI after every file is copied.

First of all let me show you the code.
In my model I have this dummy method (not the real method but the logic behind it is the same):

public void dummyMethod(Integer k) throws InterruptedException{
    for(int i=0;i<10;i++){
        System.out.println(i);
    Thread.sleep(1000);
        this.firePropertyChange(DefaultController.BACKUP_DUMMY, i-1, i);
    }
}

In my view I have this:

@Override
    public void modelPropertyChange(PropertyChangeEvent evt) {
        // .......


        else if( evt.getPropertyName().equals( DefaultController.BACKUP_DUMMY ) ){
            System.out.println("WHAT?");
            this.dummy.setText(evt.getNewValue().toString());
        }

    }

As you can imagine the WHAT? is printed every time but the GUI is not updated until the loop has finished is thing.
That’s the classic problem when you’re working with SWING and its EDT and I’ve read on the oracle site this article/tutorial but I don’t think I need to use a SwingWorker. I just need to update a single component on the GUI.

  • 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-05-19T21:55:21+00:00Added an answer on May 19, 2026 at 9:55 pm

    Do not use event dispatch thread for long running operation. You should start another thread for long running operation such as file copying. If you need to update your gui from the worker thread, you should use SwingUtilities.invokeLater or SwingUtilities.invokeAndWait methods..

    as an example ;

    final JLabel label = new JLabel();
    JButton button = new JButton();
    button.addActionListener(new ActionListener() {
        public void actioPerformed(ActionEvent ev) {
             Thread workerThread = new Thread() {
                   public void run() {
                         //do long running job then update ui
                       SwingUtilities.invokeLater(new Runnable() {
                               public void run(){
                                   label.setText("Operation has finished");
                               }
                        });
    
                   }
             }.start();    
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our desktop application, we have implemented a simple search engine using an inverted
I have a desktop application written in C#. It is trying to manage a
I have a .Net desktop application with a TreeView as one of the UI
I have an Java desktop application which connects directly with the DB (an Oracle).
I have a desktop (winforms) application that uses a Firebird database as a data
In a desktop application needing some serious re-factoring, I have several chunks of code
I am in a Windows Desktop application and I have a data stream and
I am developing a Java desktop application and would like to have an external
I have a large tree of Java Objects in my Desktop Application and am
I have a custom class loader so that a desktop application can dynamically start

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.