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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:44:41+00:00 2026-05-24T23:44:41+00:00

I am currently developing an HTTP application using Apache’s http API and I am

  • 0

I am currently developing an HTTP application using Apache’s http API and I am using a GUI. After after every GET or POST request I want to update a GUI TextArea with some messages. The problem is that those messages appear after all the requests are done.

I also noticed that if I write messages on the console after every request, the message appear, but if I write on the GUI all the messages appear on the end.

Here is some code snippets:

GUI constructor:

public GUI() {
        initComponents();
        SetMessage.gui = this;
}

SetMessage class:

public class SetMessage implements Runnable{

    public static GUI gui;
    private String msg;

    public SetMessage( String msg){
        synchronized(gui){
            this.msg = msg;
        }
    }

    public void run() {
        gui.setText(msg);
    }

}

The GET request class (every request is made by a thread):

public class SendGetReq extends Thread {

private HttpConnection hc = null;
private DefaultHttpClient httpclient = null;
private HttpGet getreq = null;
private int step = -1;
private String returnString = null;

public SendGetReq(HttpConnection hc, DefaultHttpClient httpclient, HttpGet getreq, int step) {
    this.hc = hc;
    this.httpclient = httpclient;
    this.getreq = getreq;
    this.step = step;
}

@Override
public void run() {
   // CODE
}

And HttpConnection Class (the instance of this class is created when I press a button on the GUI):

    public class HttpConnection {
        private DefaultHttpClient httpclient = null;
        private HttpGet getreq = null;
        private HttpPost postreq = null;
private SendGetReq tempGet = null;
         // More fields
        private void RandomMethod(){
//Initialize getreq
(tempGet = new SendGetReq(this, httpclient, getreq, 0)).start();
new SetMessage("Message").run();

}

Oh! And the GUI’s SetText method:

public synchronized void setText(String msg){
        if(!"".equals(msg)){
            Date currentDate = new Date();
            Calendar calendar = GregorianCalendar.getInstance();
            calendar.setTime(currentDate);
            jTextArea1.append(calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND)+" --- "+msg+"\n");                        
        }
    }

Can anyone help me with this problem? Thanks!
}

  • 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-24T23:44:42+00:00Added an answer on May 24, 2026 at 11:44 pm

    Yup, pretty standard behaviour for a GUI. You will need to do the HTTP requests in another thread, then notify the GUI thread to update the UI. Swing in particular demands that the UI is updated from a single thread, the event dispatching thread to be precise.

    See SwingUtilities#isEventDispatchThread(), SwingUtilities#invokeLater() and the SwingWorker class.

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

Sidebar

Related Questions

I'm currently developing an Android application that fetches images using http requests. It would
Currently developing an application using the newest version of symfony, obtained through PEAR. This
I was currently developing a desktop application in C# using mono and testing in
I am currently developing a Rails application using a database that was designed before
I'm currently developing a PHP application that's using an Access database as a backend.
I'm currently developing a WPF application in C# and I want to have a
I am currently using Visual Studio 2008 on XP Pro SP3. Developing against http://localhost/
I'm currently developing an API for my application on RoR As an example, I
I am currently developing a Web-Application using Java EE where I'm using a Rich-Javascript-Editor
I am currently developing an events calendar application using ASP.NET MVC and SQL Server

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.