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

  • Home
  • SEARCH
  • 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 5956735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:18:00+00:00 2026-05-22T18:18:00+00:00

Good day! I develop program client-server and met one problem and i really don’t

  • 0

Good day!
I develop program client-server and met one problem and i really don’t know how to solve it.

So, i have few buttons. When button clicks then info sends to the server, server does some work and sends result. Listener of button receives that and then call method of other class which must draw the result on screen.

So, here is problem. Server sends me few results and program must draw it instantly. But it doesn’t do that! It waits till all messages will come and ONLY then draws result.

So i want to know how to draw result on the screen instantly!

Code:
Listener of Button:

public class ShowFrame extends JFrame
{
    startButton.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e)
       {
            try 
            {
                messageToServer.println("Start");

                while( true )
                {
                    fserver = answerOfServer.readLine(); //Get result from server

                    if ( fserver.equals("Finish") )
                    {
                        break;
                    }
                    if( fserver.equals("Busy 1") )
                    {
                        ShowFrame.this.stuff.setBusy( 1 );
                    }
                    if( fserver.equals("Busy 2") )
                    {
                        ShowFrame.this.stuff.setBusy( 2 );
                    }
                    //...Same code


                }
            } catch (IOException ex) {
                Logger.getLogger(ShowFrame.class.getName()).log(Level.SEVERE, null, ex);
      }

    DrawStuff stuff = new DrawStuff();
    //...
}

Class which draw result on the screen:

public class DrawStuff extends JComponent
{

public DrawStuff()
{
    s1 = false;
    s2 = false;
    s3 = false;
    s4_1 = false;
    s4_2 = false;
    s4_3 = false;
}

@Override
public void paintComponent( Graphics g )
{
    Graphics2D g2 = (Graphics2D) g;
    //...
        if ( s1 )                     
        {
                g2.draw(line1_of_P1);
                g2.draw(line2_of_P1);
        }
        //...
 }

public void setBusy( int i ) //If such id found then figure will be drawn by prog.
{
    if      ( i == 1 )
    {
        s1   = true;
    }
    else if ( i == 2 )
    {
        s2   = true;
    }
    else if ( i == 3 )
    {
        s3   = true;
    }
    else if ( i == 4 )
    {
        s4_1 = true;
    }
    else if ( i == 5 )
    {
        s4_2 = true;
    }
    else if ( i == 6 )
    {
        s4_3 = true;
    }
    this.repaint(); //DOESN'T WORK AS IT MUST!

}
//...
}
  • 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-22T18:18:01+00:00Added an answer on May 22, 2026 at 6:18 pm

    You execute reading in event dispatch thread and it’s not good. You should do it in separate thread (because it is long running task). See http://download.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

Good day everyone. This problem was part of another one which it as been
Good day, I have this problem with Html.DropDownListFor which I can't seem to work
Good day to all. I have the flowing problem. I have 2 domains. On
Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
Good day, I have a question here. I am trying to fetch image from
Good Day! i have installed xcode latest in my snow leopard, now i have
Good day. I have to pass the session value to a business logic layer,
UPD: Solved! Good day! I started develop JAVA GUI apps in netbeans 6.9.1 (I
Good day everyone. Recently I was given a task to develop an application to
Good day shell lovers! basically i have two files: frequency.txt: (multiple lines, space separated

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.