Java code for GUI of a chat program

Share this article

I worked on the GUI of a chat program in Java. I would like to share the experience as well as codes of my program. The code which I am going to share is a stand alone GUI i.e. its not a complete chat program but just the windows without any connectivity. (I’ll also upload the running version of the complete program sometime later).

It consists of three classes, LogInWindow, ConnectWindow, ChatWindow. The features of these classes are as following:

LogInWindow:

It consists the main and the whole code is run by this class. When it runs for the first time it automatically calls ConnectWindow so that user can provide detail about itself like its name, nick name, port number etc. There are (in this example predefined) a no. of users as buttons. Clicking on a user (Buttons) opens a ChatWindow. When you exit the LogInWindow the whole program exits. The window is named “WeChat”. There are two menu option in menu bar. One is to change status and one is to connect and terminate the chat. Various Status option are:

  • Available
  • Do Not Disturb
  • Away
  • Invisible

Connexion consists of two option: Connect and Terminate. Clicking on Connect allows the user to put info about itself in the ConnectWindow (If user has already done it then it shows the previous entries). Terminate deletes all the previous info about the user.

ConnectWindow:

It allows user to put info about itself. Already discussed in LogInWindow.

User can put the following information:

  • First Name
  • Last Name
  • Nick Name
  • Display Name
  • Status Message
  • Port Number

Pressing Ok Button enters these information. Clicking on cancel simply disposes the window

ChatWindow:

Chat Window class provides different facilities for interacting with other user. It has a text field where user can enter chat. All the text is shown in a text area. There are some buttons for Voice and Video Calls as well. The chat transcript can be saved easily by clicking the save button. Closing the chat window disposes it. And it also gives calls a function while closing the chat window (So that it can be used to pass info about the closing the chat window to some other class/module, if needed).


P.S. You can find the codes here (All the code are in word file. You can copy paste these codes in txt file): GUI Code

  • Ze Fiasco

    Hey, can you send me the code for the full project, I am trying to build an audio/video LAN chat and I am having serious issues!

    • http://itsfoss.com/ Abhishek Prakash

      Unfortunately, I don’t have the code anymore. It’s been several years for this post and I have lost it from my back up.

  • Shawn

    Need Code

  • matuz

    can u give the source code

  • Varsha

    Hey when do u think you’ll be sharing you’re code?

    • https://computerandyou.net/ Abhishek Prakash

      code just for GUI or for the whole application?

      If you need the whole application. please give me your email id.. I’ll check if I still have the whole code.

  • anh

    hi,thanks for sharing . i need code of this program,you can share to me! ?

    • http://computerandu.wordpress.com Abhishek Prakash Chaturvedi

      Hi Anh,
      You want the GUI code or the whole code?
      Actually we used XMPP protocol for this project which made things really very complicated. It is a bundle of numerous classes. Architectural fault from our side.

      Tell me if you still want the code.

  • Vijay Nagrajan

    Hi,
    Thanks for sharing it. If I can ask, do you have the rest of the codes, I mean code for full chat program?
    I am working on a similar project and can take help from your codes.
    Thanks in advance

    • http://computerandu.wordpress.com Abhishek Prakash Chaturvedi

      hey,
      May be I’ll share the whole code. But right now I am still working on that.
      Keep checking.