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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:10:26+00:00 2026-06-04T23:10:26+00:00

I have a code right below…take a look. enter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent

  • 0

I have a code right below…take a look.

enter.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (enter.getText().length()>0){

            addToChat("You: "+enter.getText());
                enter.setText("");
                delay(1000);
                addToChat("oie");
            }

        }
    });

And here is the delay void.

  public static void delay(int delayTime){
    try
    {
        Thread.sleep(delayTime);
    } catch (InterruptedException ie)
    {
    }
}

The problem is whoever I type something into the text box and hit enter, it takes one second for not only the one to show up in the text area, but also the “You: ” text block to show up, which is before the delay. Why is this delay affecting things BEFORE it and how can I fix this?

  • 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-04T23:10:27+00:00Added an answer on June 4, 2026 at 11:10 pm

    The UI does not get a chance to update before your action listener is finished. If you would like to change something after the delay, you should schedule it on a different thread, rather than wait inside the event handler:

    addToChat("You: "+enter.getText());
    enter.setText("");
    new Thread(
        new Runnable() {
            public void run() {
                delay(1000);
                addToChat("oie");
            }
        }
    ).start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure if I'm phrasing my question right, but I have the code below.
I have a problem with this code right here: - (void)fetchedData:(NSData *)responseData { //parse
Okay right now I have too include the code below on every single page
So basically, the below is the code I have right now: class MY_Log extends
I have below code in vb.net. <tr> <td align=right> <b>Course Date:</b> </td> <td> <asp:TextBox
I have code like this: class Base { public: void operator = (const Base&
I am new to jquery and still learning. The code I have right now
I have the below code and it works but what is the right way
I have some code right now that executes when a link is clicked. The
I have this code right now to get the row value from jquery grid..

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.