Click here to Skip to main content
15,894,460 members
Articles / Desktop Programming / Swing
Article

Talk2Me: Java instant messenger

Rate me:
Please Sign up or sign in to vote.
4.70/5 (95 votes)
3 Feb 2004CPOL3 min read 968.8K   23K   120   345
A near to perfect clone of the very popular Yahoo messenger. Purely written in Java and SWING, this messenger also uses the capabilities of JNI and JAWT to provide some features.

Sample Image - Talk2Me.jpg

Introduction

What I am trying to introduce here is a full fledged Java Instant messenger, which has all the features supplied by commercial messengers like Yahoo or MSN. Although it cannot compared to be in par with those messengers, it is an attempt by me to learn Advanced Java and JNI concepts. The challenges I faced here were often overcome by referring to numerous sites, which nearly zeroes in or completely solved the issues I faced at that point of time. It improved my learning curve and also believe would do the same to you too. Ofcourse, there are some bugs and glitches, which I hope you would excuse. Thanks to anyone who takes the pain to report them or even suggest better way of doing things to me.

System Requirements

Window/WinNT/Solaris(To run the chat server)
Windows/WINNT (For running the chat client)
JDK Ver1.3 or higher(Although I havent tested with lower versions of that)

Challenges faced

1. Building the Server and Client framework code. The Server and Client use TCP sockets to communicate and a MESSAGE java object is passed across the server-clients. MESSAGE object is serialized and sent as a bytes through the TCP socket.
2. Building the SWING component. The Client bears all the complexities of java.Swing and puts few of the Swing components to the rubber test.The Server is a purely console based client as oppposed to Client. The Client uses Swing components extensively, the following are worth a mention.

Userlist - JTree whose L&F is similar to that of YAHOO's,which is updated on Client login,logout and status change.
ChatDialog - JFrame with JTextArea for typing a message and JEditorPane for displaying received messages. The reason why I chose JEditorPane is the ability to display HTML text. This helped me to easily add smileys and other HTML tags like FONT,IMG etc. Try all the YAHOO smileys here like :), >:), :)) etc and see the results.
ConferenceDialog - Similiar to ChatDialog and has a JList component in addition, to display the available users list.
JWindow - To display a splash screen. The picture was of course drawn by me.
System Tray Icon - To minimize the chat to the System tray was one of the primary features of an instant messenger. This was achieved using a JAWT call. The following of code complete with source is available in the following site, kudos to its creator.
http://jeans.studentenweb.org/java/trayicon/trayicon.html[^]
Flashing Window - Was achieved through a JNI call, which calls the Win API all FlashWindow(HWND,BOOLEAN) and a javax.swing.Timer to flash the window.

Steps to run

1. Unzip the contents of the zip to a folder. Make sure you have the following files in that directory.
Talk2Me.jar
TrayIcon12.dll
Client.dll


2. Go the directory and run the server first. The command is,
java -classpath Talk2Me.jar Server
(To run the server doesn't need dll's and Server can run in any m/c WIN/SOLARIS provided it has JDK installed)

3. Now start the Client.
javaw -jar Talk2Me.jar (WINDOWS only)
On most machines, just double clicking the JAR would invoke the program)

4. Give any username and password and make sure you give the right Server IP where the server is running, in the Login dialog. It can be valid names like localhost, 127.0.0.1, 172.22.11.88...etc.

Note

I wrote this messenger purely to serve as a knowledge base to other programmers. Please refrain from using this messenger for commercial purposes or whatsoever. Anyone who wishes to modify the code to suit their own requirements, please seek my consent before doing so. Please make sure that you mail me the exact purpose why you want to modify the code.


That's it folks. I've tried my best to make my code understandable and ofcourse there is always more than one way to do anything and it would be helpful If you could suggest me a better way of doing things. Your comments and feedback are always welcome.


Thanks and Happy messaging.

Alfred Jayaprakash

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
Currently in Chennai, India, working as a Developer for the last 4 years. A MFC/VC++ fanatic who actually lacks professional experience in the same. Worked to the hearts content in C,C++,Perl,Java,J2EE and C# all web based technologies. Also loves Dancing, Dramatics and painting and a self learnt Guitarist.

Comments and Discussions

 
QuestionHow to create jar file of that project ? Pin
arshadontheweb10-Apr-08 7:35
arshadontheweb10-Apr-08 7:35 
AnswerRe: How to create jar file of that project ? Pin
jongwons.choi16-Jun-08 14:59
jongwons.choi16-Jun-08 14:59 
QuestionQuestion about Conference Chat???? Pin
mocs241857-Apr-08 23:04
mocs241857-Apr-08 23:04 
Questioni am getting an error "cannot load client dll" [modified] Pin
kaumudi7-Apr-08 9:38
kaumudi7-Apr-08 9:38 
Generalhiiiii plz help me Pin
sowmyas2-Apr-08 4:05
sowmyas2-Apr-08 4:05 
GeneralHelp me!!! Pin
dhanuchavan23-Mar-08 17:18
dhanuchavan23-Mar-08 17:18 
GeneralPLS SEND ME THE FULL SORCE CODE OF ALL THE JAVA FILES Pin
hem.geek20-Mar-08 22:57
hem.geek20-Mar-08 22:57 
Generalpllllllllllllllllz hellllp Pin
NERAM1-Mar-08 20:49
NERAM1-Mar-08 20:49 
Confused | :confused:


Magic Squares






A magic square is an n*n matrix in which each of the integers 1,2,3…n^2 appears exactly once and all column sums, row sums, and diagonal sums are equal. For example, the following is a 5*5 magic square in which all rows, columns and diagonals add upto 65. The magic number can be calculated according to the following equation : Magic = Sum (1..n^2)/n.


17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9



The following is a procedure for constructing an n*n magic square for any odd integer n. Place 1 in the middle of the top row. Then after integer k has been placed, move up one row and one column to the right to place the next integer k+1, unless one of the following occurs:
• If a move takes you above the top row in the jth column, move to the bottom of the jth column and place k+1 there
• If a move takes you outside to the right of the square in the ith row, place k+1 in the ith row at the left side
• If a move takes you to an already filled square or if you move out of the square at the upper right-hand corner, place k+1 immediately below k.



Write a program to construct n*n magic square for any odd value of n. Your program should provide the facility for the user to input the numbers in any desired position (given it is free). Your program should check the user’s input to verify that it results into a magic square. If this condition is valid you congratulate the user, otherwise you generate the right answer for the user. The user is allowed to play the game as many times as he/she wants, when the user chooses to end the puzzle, your program should tell him his score (number of times he managed to solve the puzzle/number of games).

Input
Max dimensions of the array
The user will then play the game by placing numbers from 1..n^2 on the board

Output
Solution of the puzzle in each time the user chooses to play
User’s percentage
Generalhelp me out Pin
omkar_me10-Jan-08 13:38
omkar_me10-Jan-08 13:38 
GeneralAbout Socket connection Pin
superda2-Jan-08 21:33
superda2-Jan-08 21:33 
GeneralCannot load Client.dll Pin
Umar Mohammad18-Nov-07 0:25
Umar Mohammad18-Nov-07 0:25 
GeneralRe: Cannot load Client.dll Pin
rohan.iiitc7-Jan-09 20:58
rohan.iiitc7-Jan-09 20:58 
Generalhai gud evening Pin
tjyothi27-Sep-07 0:59
tjyothi27-Sep-07 0:59 
Questionsend me reports of java progamming Pin
pam24247523-Aug-07 19:43
pam24247523-Aug-07 19:43 
Generalproject work Pin
oseiNana13-Aug-07 0:16
oseiNana13-Aug-07 0:16 
QuestionCOnvert JTree to JList Pin
lukmanjaji18-Jul-07 10:57
lukmanjaji18-Jul-07 10:57 
AnswerRe: COnvert JTree to JList Pin
lengy19-Jul-07 22:43
lengy19-Jul-07 22:43 
GeneralRe: COnvert JTree to JList Pin
lukmanjaji20-Jul-07 3:14
lukmanjaji20-Jul-07 3:14 
Generalthis application is C++ code dependent Or can work with jdk only Pin
Syed Saifuddin16-Jul-07 1:00
Syed Saifuddin16-Jul-07 1:00 
Generalhelp Pin
enzo_sonne23-Jun-07 7:22
enzo_sonne23-Jun-07 7:22 
QuestionHELP ME!! Pin
BinVin11-Jun-07 3:40
BinVin11-Jun-07 3:40 
AnswerRe: HELP ME!! Pin
lengy12-Jun-07 13:08
lengy12-Jun-07 13:08 
GeneralNot able to run Pin
Mangat Rai3-Apr-07 21:33
Mangat Rai3-Apr-07 21:33 
Generalcannot run Pin
basseyra armain28-Mar-07 16:35
basseyra armain28-Mar-07 16:35 
Generalabt .mf files Pin
sudersan25-Mar-07 22:47
sudersan25-Mar-07 22:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.