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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:02:30+00:00 2026-05-27T14:02:30+00:00

i have rather very basic question. I have one GUI class and another which

  • 0

i have rather very basic question. I have one GUI class and another which does some background processing. Normally i have some methods in background class (which consist of multiple threads), which can return the result when called and i can use the result in GUI class.

But now i have this strange problem that the GUI has to display something, which requires background class to call external process and once connected to this process, the connection will remain open, and as such i can not return anything unless the stream is closed. However the process keeps sending data which needs to be displayed on GUI

If i put both in the same class, i can do so; by simple calling e.g JLabel.setText(what ever coming from external prcess in infinite while loop). However if it is in a different class, i can not access this JLabel or any such component from another class. If i declare them static, the GUI throws exception, is there anyway i can avoid this, or the only option to write the code together in the same class with the GUI

  • 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-27T14:02:31+00:00Added an answer on May 27, 2026 at 2:02 pm

    You have two problems to solve.

    First, you need a means to communicate from one class to the other. There are many ways to solve this problem. For example, you could have the worker class publish events subscribed to by the GUI class. Or you could pass to the worker class a reference to the GUI object (possibly as an interface type).

    Second, you need to update the GUI only from the event-dispatch thread. You can do this primitively with SwingUtilities.invokeAndWait(Runnable) or SwingUtilities.invokeLater(Runnable). Or you can use the higher-level framework provided by the SwingWorker class.

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

Sidebar

Related Questions

I have a very basic question: Why did Twitter choose Scala rather than Groovy
So i have this very basic ipad view controller and i was doing some
I have a rather large (freeware) project written with Delphi 2007 which is using
I have a very basic web page that uses flot to create a canvas
I have a very basic form at http://www.happyholidaylites.com/contact.html and it is working great. When
While trying to learn c++, I tried to implement class representing very basic trie.
I have a very basic two-page website: the home page, and an about page.
I'm trying to use System.Diagnostics to do some very basic logging. I figure I'd
this is might be a very basic question, but seems like it's not easy
does J2ME have something similar to RandomAccessFile class, or is there any way to

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.