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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:05:21+00:00 2026-06-07T04:05:21+00:00

I was developing a swing application which calls multiple methods & initializes different classes.

  • 0

I was developing a swing application which calls multiple methods & initializes different classes.
Also I have multiple threads in which they process intermediate results. My requirement is to display that intermediate data on some labels and text boxes on the fly.

Please help me which of the below approach is best in terms of memory and performance.

  1. I can have setter methods for all my labels and text boxes. So that I can call these methods using that swing class object but in that case I need to pass the swing class object to every class wherever I want to set the data to labels.
  2. Another way is I can create public static object of my swing class and I would call it from any class whenever I need to set the label text.

First method creates more overhead as I need to pass the my Swing class object to other classes.

Second method is easiest way but creating static objects might create confusion as this application contains threads.

I just want to know which one to go for and why?

Otherwise if anybody have worked on some complex swing app development – how did you manage these kind of issues?

  • 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-07T04:05:24+00:00Added an answer on June 7, 2026 at 4:05 am

    This example is typical of your first approach in a multi-threaded context. For expedience, the model and view are tightly coupled: each worker thread receives a reference to the label it should update. The alternative is loose coupling: each view registers to listen to the model, which notifies all registered listeners using the observer pattern.

    This simpler example uses both approaches:

    • Tight coupling: The worker obtains a reference to its target label in an enclosing scope.

    • Loose coupling: The enclosing view registers a PropertyChangeListener, which the model uses to signal the view via setProgress().

    You’ll need to decide which is important in your application. I agree with @JB Nizet’s comment about the second approach.

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

Sidebar

Related Questions

I'm developing Swing application, and everything works fine usually. But I have an GUI
I'm developing an application that features multiple Swing GUIs. The main GUI has a
I have a server application and two Swing-based client applications. We're developing them in
I'm new to Java Swing & I'm a bit stumped. The application I'm developing
I am developing a Java Swing application but I want to also use JavaFX
I am developing an application [desktop swing application] which requires me to do refactoring
I am developing an application in which i have to read the contents of
I am developing a desktop app using Java and Swing Application Framework. I have
I'm developing a Java Swing application which contains a JTable . By default, while
I am developing a server-client application in which the client calls a server's API

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.