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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:18:26+00:00 2026-06-13T13:18:26+00:00

I have a program that gets input from the user via swing through a

  • 0

I have a program that gets input from the user via swing through a function I’m calling in main. The submit button has an action performed method attached to it. I’m trying to get it to repaint the screen after removing the input files and setting the text to inform the user. It doesn’t do the repaint until after the try/catch with a custom function in it. Not sure what I’m doing wrong I though it would execute in order? Below is my Action preformed attached to my submit button. One note is that if I do a frame.dispose() or setVisibility(false) it will remove the frame, any help would be appreciated. Thanks!!

    button.addActionListener(new ActionListener (){

                public void actionPerformed(ActionEvent e) {
                    loc = FileLoc.getText();
                    name =  FileName.getText();

                    //inform user
                    area.setText("Attempting To Run Test....");
                    //backGroundPane contains the user input fields and button      
                    frame.remove(backGroundPane);
                    frame.repaint();

                    if(loc != null && name != null && 
                            !loc.equals("") && !name.equals(""))
                    {
                        try {
                            CallDrivers();
                        } catch (InterruptedException e1) {
                            System.out.println("Error Running Function");
                            //e1.printStackTrace();
                        }
                    }
                    else{
                        area.setText("There are Blank Fields");
                        System.out.println("test");
                    }
                }});
  • 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-13T13:18:27+00:00Added an answer on June 13, 2026 at 1:18 pm

    You are blocking the EDT (Event dispatching Thread).

    The event dispatching thread is reponsible of dispatching all UI-events, one at a time, in the order the have been posted. Events can be amongst:

    • Key event (user pressed a key for example)
    • Mouse event (user moved the mouse for example)
    • Invocation event (you called SwingUtilities.invokeLater() or JComponent.repaint() for example)
    • Paint event (request for painting a component)
    • Action event (logical event triggered by an InputEvent that occured)

    When you call repaint you are pushing an event on the queue, but as long as the current event (the one of the actionPerformed) is not done, the repaint cannot occur. This is why your repaint only occurs after your try/catch has completed

    Read more here: http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html

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

Sidebar

Related Questions

I have made a program that gets some strings in input from the user
I have a program that gets a JSON from the server using getJSON and
I have created the output for a program that allows a user to input
I need to write a program that gets three numbers from the user, then
I need to write a program that gets a string from the user and
I have a Windows C program that gets its data through a redirected stdin
I have a program that calls a Filewatcher function, like this Main() { watch();
I have a Cocoa application that gets the input from an NSScrollView and then
I have a Java back-end that produces updates from an input by user of
I have a program that gets the FOV angle of the device's rear-facing camera,

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.