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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:53:08+00:00 2026-05-26T22:53:08+00:00

I am trying to wirte java-program. My Idea: The main class launches thread for

  • 0

I am trying to wirte java-program.

My Idea:
The main class launches thread for socket connection, also the main class launches Frame with GUI.

package dialogsubsystem2;

import InternetConnection.SocketConnectionThread;

/**
 *
 * @author ACER
 */
public class DialogSubsystemLauncher {

    public SocketConnectionThread connectionSocket = new SocketConnectionThread("192.0.0.100", 2002);

    public DialogSubsystemLauncher() {

        /* Create and display the form */

        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new DialogSubsystemLayoutFrame().setVisible(true);                
            }
        });        

        connectionSocket.start();        
    }


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

       DialogSubsystemLauncher dlgLnch = new DialogSubsystemLauncher();


    }
}

The created Frame launches another frames by request from user.

I want to show information about the socket connection (from socket connection thread) on statusbar of all Frames.
But I can’t to access the socket connection thread from Frames.
How should I solve this problem?
How should I launch socket connection thread to have access to it from any Frame?

  • 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-26T22:53:09+00:00Added an answer on May 26, 2026 at 10:53 pm

    You need that one of the objects has a reference to the other. I would point to the frame having a refence to the thread (since the thread may be blocked at times by I/O).

    Just make the constructor of the Frame accept a thread object and pass the one you created(or add a set method to it).

    EDIT:

    In answer to aclarations in comments.

    It is to the other classes (the Frames) that you create that you need to pass the reference.

    public class DialogSubsystemLayoutFrame extends JFrame {
      // You store the reference here.
      private SocketConnectionThread socketConnection = null;
    
      public DialogSubsystemLayoutFrame(SocketConnectionThread socket) {
        this.socketConnection = socket;
      }
    }
    

    From there, you can use this.socketConnection anywhere in the class to operate with it.

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

Sidebar

Related Questions

I am trying to write an application that uses java.net.Socket. I have also written
I am trying to write a Java program that reads an input file consisting
I'm trying to follow Java's JDBC tutorials to write a Java program that can
I'm trying to write a program in Java that uses osql to generate a
I am trying to write a Java class to extract a large zip file
I am trying to write a java application connecting to server connection channel with
I am trying to write a java program that will automatically download and name
I'm trying to write a program in Java that when given an MxN matrix
For my data structure class, I am trying to write a program that simulates
I am trying to write a Java program to calculate factorial of a large

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.