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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:42:36+00:00 2026-06-03T00:42:36+00:00

I have a client/server MMORPG I am working on and I want to do

  • 0

I have a client/server MMORPG I am working on and I want to do things correctly(as impossible as it is). My questions is: What is the best way to pass references to my GUI items(JInternalFrame, JPanels, etc.) to my class that listens to commands/replies from the server. Right now this is what I have going on, which will soon grow quite large.

MyCommandReciever(DataInputStream commandIn, DefaultListModel modelUserList, JInternalFrame skillsFrame, Container skillsPanelHeader, Container skillsPanelContent, JInternalFrame characterFrame){
    this.commandIn = commandIn;
    this.modelUserList = modelUserList;
    this.skillsFrame = skillsFrame;
    this.skillsPanelHeader = skillsPanelHeader;
    this.skillsPanelContent = skillsPanelContent;
    this.characterFrame = characterFrame;
}

I don’t want to keep passing more and more JInternalFrames to MyCommandReciever.

Does it make sense to do something like this??

Component[] c = panel.getComponents();
for(int i = 0; i < c.length; i++) {
    System.out.println(c[i].getClass().getSimpleName());
}

Or is there a way that I can create an instance of my Main class(which includes my GUI), from within my main class, and pass that to MyCommandReciever so it has access to everything(maybe like this):

MyCommandReciever(DataInputStream commandIn, DefaultListModel modelUserList, MyClient m){

If this last approach is the way to go(which I’m hoping it isn’t, do I need to pass it from the class that creates an instance of it(Character.java creates instance of MyClient.java), to itself(MyClient.java), and then pass it from MyClient.java to MyCommandReciever.java?

Sorry if that last question was too confusing… let me break it down:

Inside Character.java:

if (playSuccess.contains("true")){
    z++; //to turn off the commandIn functionality in Character screen when MyClient is running
    frame.dispose();
    new MyClient(accountName, playWho, commandIn, messageIn, commandOut, messageOut, sM, sC);

Inside MyClient.java:

commandReciever = new MyCommandReciever(commandIn, modelUserList, skillsFrame, skillsPanelHeader, skillsPanelContent, characterFrame);

so in the character.java I would have to create instance of MyClient(and assign to variable) but at the same time pass that assigned variable to MyClient. (now that I’m typing this it doesn’t even seem possible).

Please guide me 😀 Clearly I wrapped my brain on this last idea.

  • 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-03T00:42:37+00:00Added an answer on June 3, 2026 at 12:42 am

    This is the approach that I decided to go with. Thanks for the other advice however it seemed a bit complex for my needs:

    In my main gui class:

    commandReciever = new MyCommandReciever(commandIn, this); //passing in instance of my main gui class
    

    In my command receiever class(class that talks to server):

    MyClient m; //for access to the GUI pieces
    
    MyCommandReciever(DataInputStream commandIn, MyClient m){
        this.commandIn = commandIn;
        this.m = m;
    }
    

    Example of how I edit my main gui class’s components from my command receiver class:

    m.modelUserList.clear();
    for (int i = 0; i < CharactersList.length; i++){
        m.modelUserList.addElement(CharactersList[i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have client/server data passing all working correctly. Text, Images, etc. My users create
Suppose you have a client/server application, say a webserver component and a qt gui.
I have a client/server program and I want to make sure that its components
I have a client / server application made with C#. Its working fine when
I have client server application using distributed object. some time my code is working
I have a client/server question that i am trying to figure out the best
I have a Client-Server Perl program. I want to send a message stored in
I have a client/server set up and I want my client to know if
I have client/server applications and a very simple protocol for communication. More precisely, it's
We have client server based app which saves user related data into a zip

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.