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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:37:32+00:00 2026-05-14T09:37:32+00:00

i have written a standalone connect 4 game. next i would like to be

  • 0

i have written a standalone connect 4 game.

next i would like to be able to play it over network and also have a chat function.

connect 4 GUI (JFrame) holds -> connect 4 game model

i would like to implement connect 4 network GUI(JDialog) (here the user can choose to act as a server or client) that holds Network API. (server only serving a single connection)

and finally a Chat GUI (JDialog) to exchange messages.

my question is how do i implement inter class/GUI communication? when a network message is received it ought to be delivered to the right receiver (game / chat) also messages sent from chat / game transmitted to remote machine.

i have looked into inner classes but was told it is a bad idea to implement so much with in single class and i did not like this idea a lot either.

i have written another game battleships in C# and it uses delegates to accomplish this task but sadly im informed that delegates are not available in Java.

im a beginner and at the moment exploring options so im open to your guidance.

thank you.

  • 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-14T09:37:32+00:00Added an answer on May 14, 2026 at 9:37 am

    There are two issues here.

    First, you must remember that all GUI operation must be issued from the Swing’s Event Dispatching Thread (EDT). So, if another thread (such as the thread listening to network messages) want to update the GUI it must use SwingUtilities.invokeLater as follows:

     // Network thread
     final Message msg = getMessage();
     SwingUtilities.invokeLater(new Runnable() {
       public void run() {
          // This code will be executed on the EDT
          // it can access the msg variable because it is final
       }
     });
    

    The second point is that of coordinating the GUI objects and networking objects. I think the best approach is to create two Mediator classes that will receive notifications from the networking object and “translate” them into appropriate action on the GUI object (and vice versa). These mediators will also make sure that GUI events are dispatched on the EDT, as explained above.

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

Sidebar

Related Questions

I have a written C++ server app that I would like to be able
I would like to build a simple standalone solitaire game in ruby. Are there
I have written a small Perl script and now I would like to create
I have written a function that sorts a big scale of data. To test
I have written a function that extract the domain from hostname. e.g. www.domain.com ->
I have a simple standalone application written in Visual Basic that I'm porting to
I have some scripts written with d3.js that generate SVG charts. I'd like to
I have written standalone application which is working in Windows Azure as startup task.
I have written a program that is sort of an unofficial, standalone plugin for
I have a standalone Java application written with Apache Camel which I want 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.