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