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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:15:31+00:00 2026-06-02T17:15:31+00:00

I am trying to implement a progress JDialog in Java. I am parsing files,

  • 0

I am trying to implement a progress JDialog in Java. I am parsing files, and I want the JDialog to refresh after I started to parse a new File. My problem is that the JDialog is not refreshing. I have tried to repaint it, or resize it, so it would repaint. I have also tried to remove the label, and add a new one.

The ProgressDialog class:

public class ProgressDialog extends javax.swing.JDialog {
    private JLabel jLabel1;

    public ProgressDialog(Window frame) {
        super(frame);
        this.setResizable(false);
        this.setLocationRelativeTo(frame);
        initGUI();
        //this.setVisible(true);

    }

    private void initGUI() {
        try {
            {
                setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
                getContentPane().setLayout(null);
                {
                    jLabel1 = new JLabel();
                    getContentPane().add(jLabel1);
                    jLabel1.setText("In Progress..");
                    jLabel1.setBounds(12, 12, 215, 52);
                    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
                }
            }
            this.setSize(255, 114);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setText(String s){
        this.setVisible(true);
        jLabel1.setText(s);
        this.resize(this.getSize());
        this.repaint();
    }
}

How I use it:

ProgressDialog pd = new ProgressDialog(frame);
for(File file:files){
    pd.setText("Parsing " + file + ".");

    ...

}
  • 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-02T17:15:35+00:00Added an answer on June 2, 2026 at 5:15 pm

    You should perform the parsing of the file on a worker thread, and update your progress dialog on the Event Dispath Thread. A few links worth reading:

    • Concurrency in Swing
    • How to use progress bars tutorial: although it shows progress with a progress bar, the mechanism you need to use is the same. It contains an example of the SwingWorker class
    • The SwingWorker javadoc
    • A small piece of sample code I wrote for a related question illustrating the use of the SwingWorker class and showing progress to the user
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement the progress notification mechanism when copying files. I'm doing this
I am trying to implement async file upload with progress with sonatype async http
I am trying to implement the SVProgressHUD progress activity indicator. I copied the class
While trying to implement an MVC file upload example on Scott Hanselman's blog. I
im trying to implement a custom error page, what i want to be able
I trying to implement the active record pattern using Java/JDBC and MySQL along with
I'm trying to implement a MPMoviePlayerView but I can't play the video files, I
I'm trying to implement a progress bar in WPF. I am looping through a
I'm trying to implement producer-consumer model and I got some problem with it. Consider
I'm trying to implement the jQuery File Upload Widget on my website. What 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.