Client side of the multiple user chat application. Previously, we have shown you how to send all incoming messages back to clients via ChatServer
example. Here is a simple chat client application:
As the picture above shows, the application has the following features:
- Multiple clients can chat with each other simultaneously.
- Each user have their own random color that indicates their message.
- Hitting enter key or pushing send button will send the message right away.
- Users recieve acknowledge messages from the server.
- As users receive messages, scrollBar automatically goes down.
Areas that this application needs progress:
- Need a protocol to encrypt and secure messages package to be sent.
- Sending files, emotions and notification features are missing.
- User Interface should include message status and time for each message.
- and many other features…
Things to consider using Swing library:
- Swing objects must only be accessed from only one thread (The Event Dispatch Thread)
- Forcing one thread to handle Swing components and background tasks lead application to freeze.
- In order to handle backgorund tasks, we can use either threads or SwingWorker subclass as a worker thread.
- SwingWorker allows to handle long running task that are needed to be run in the background.
- Using TextPane instead of TextArea allows you to use sytles for each line.
You can find the repository of my work in my Github page: https://github.com/iesirma/