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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:42:36+00:00 2026-06-01T13:42:36+00:00

I have created a JDialog in NetBeans and a custom constructor as follows: public

  • 0

I have created a JDialog in NetBeans and a custom constructor as follows:

public AnimatedProgress(java.awt.Frame parent, boolean modal, JTable table) {
    super(parent, modal);
    initComponents();
    setLocationRelativeTo(parent);
    progressLabel.setText("Collecting Table Data. . .");
    Object[][] data = getJTableData(table); // Simple method to collect data and store in Object[][] array
    progressLabel.setText("Processing Data. . .");
    processData(data);
    progressLabel.setText("Data Processed. . .");
}

Now I called this JDialog as:

new AnimatedProgress(this, true, dataTable).setVisible(True);

My problem is, as Java calls the constructor, all the codes in constructor gets executed first and then the dialog appears with final result.

How can I make my JDialog appears first and then process the methods: getTableData() and processData()??

  • 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-01T13:42:38+00:00Added an answer on June 1, 2026 at 1:42 pm

    Here is a sample use of SwingWorker:

    public class BackgroundThread extends SwingWorker<Void, Void>
    {
        private JTable table;
    
        public BackgroundThread(JTable table)
        {
            this.table = table;
        }
    
        @Override
        public Void doInBackground() throws Exception
        {
            /*
                If getJTableData() or processData() are not static,
                pass a reference of your class which has these methods
                and call them via that reference
            */
            Object[][] data = getJTableData(table);
            publish("Processing Data. . .");
            processData(data);
            publish("Data Processed. . .");
            return null;
        }
    
        @Override
        public void process(List<String> chunks)
        {
            for(String chunk : chunks) progressLabel.setText(chunk);
        }
    }
    

    Then change you constructor to this:

    public AnimatedProgress(java.awt.Frame parent, boolean modal, JTable table)
    {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(parent);
        setVisible(true);
        new BackgroundThread(table).execute();
    }
    

    I didn’t test it, but I hope it works.

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

Sidebar

Related Questions

I have created a modal JDialog box with a custom drawing on it and
i have created a simple public ref class in the vc++ project, which is
I have created a JDialog to be opened when I click on the edit
I have created a class which extends JDialog, where I have some checkboxes and
We have an application which, as its first UI action, displays a modal JDialog
Have created a custom navigation menu in wordpress that has some pages and some
I have created a little program that reads in a Java file and feeds
I have created a JDialog which contains a JLabel. Because the length of text,
I have created a JDialog which contains a JComboBox and a panel underneath which
I have main frame (with JFrame field) asi view , then presenter (created in

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.