AIM Client
Introduction
In this lab you will be designing, implementing and testing a Graphical User Interface (GUI) for an AIM client. Your first task will be to implement and test a chat window within which you can send and receive messages. Once that is working you will implement and test a Model-View-Controller GUI for managing a buddy list and initiating AIM sessions with buddies. Implementing this functionality will require you to use what we learned about GUI's as well as perform some exception handing and file input/output operations.
You are free to design the GUI's in any way that you like. One example of a chat window and buddy manager GUI are shown here:
Getting Started
Update the 132Labs project from the SVN repository. Instructions for updating the labs project can be found under Updating the Labs Project from the SVN Repository in the How-To Document for the course.
Before starting this lab you will also want to create at least 3 AIM accounts to use specifically for the lab. You can create new AIM accounts from the AIM Home Page by clicking on "New? Get a Username" toward the right of the page. Be sure to pick usernames that are easy to remember and consider using the same password for all accounts. I strongly suggest that you do not use any personal information when creating these accounts.
Design
The code that you will be writing for this project is divided into four classes:
AIMRunner: The main program that will create a connection to the AIM server and then bring up either an AIMChatWindow (in part #1) or a BuddyListGUI (in part #2).
AIMChatWindow: A window in which you can send and receive messages from another AIM user.
BuddyList: A model (in the MVC sense) of a list of buddy names. It is possible to add/remove buddies and also to save the list to a file and read the list from a file.
BuddyListGUI: A view/controller (in the MVC sense) for a BuddyList.
These classes will need to interact with an AIM server in order to sign on/off and to send and receive messages. You are provided with several classes that handle the details of interacting with the AIM server. You will need to make use of these classes in your code. The interfaces and relevant methods that are implemented by these classes are:
AIMSender: This interface defines methods for sending messages to the AIM server. The AIMConnection class provides a functioning implementation of this interface. You will be using an instance of AIMConnection to sign on/off and to send messages. The important methods in the AIMConnection class are:
AIMConnection(String username, String password): Construct a new AIMConnection for the specified username and password.
void signOn(): sign onto the AIM server using the username and password given in the constructor.
void signOff(): sign off from the AIM server.
boolean connected(): returns true if currently signed on to the AIM server and false otherwise.
void addAIMListener(AIMListener l): Add an AIMListener to the AIMConnection. The handleMessage method in the AIMListener will be invoked when a message arrives from someone else. See the description of the AIMListener below.
AIMBuddy findBuddy(String name): Get an AIMBuddy object representing an AIM user with the specified name. An AIMBuddy object is needed in order to send a message.
void sendMessage(AIMBuddy buddy, String message): Send a message to the specified buddy.
AIMListener: This interface defines methods for receiving messages from the AIM server. The AIMAdapter class provides a stub implementation of this interface in which all of the methods are empty. You will need to create a class that extends AIMAdapter in order to handle incoming messages from other users. The most important method in the AIMAdapter class is:
void handleMessage(AIMBuddy buddy, String message): This method is invoked when a message is received from another AIM user.
AIMBuddy: This class is a representation of someone that you are chatting with on AIM. You will occasionally need to get the user name from an AIMBuddy object. The relevant method is:
String getName(): Returns the name of the buddy.
The Assignment
This assignment is divided into two parts. In the first part you will implement the AIMChatWindow class. In the second part you will implement the buddy management functionality in the BuddyList and BuddyListGUI classes.
Part 1: Chat Window
In this part of the assignment you will build the chat window. The following steps provide a good outline for how to attack this part of the assignment:
AIMRunner class. It creates an instance of the AIMConnection class and attempts to sign on. If the sign on is successful, it then creates and instance of the AIMChatWindow class and displays it.
AIMRunner class so that it uses the usernames and passwords of the AIM accounts that you created.
AIMChatWindow class. The large text area should be a JTextArea component, the message box should be a JTextField object. You should get the GUI to display correctly before attempting to handle any events.
ActionListener to the "Send" button that sends the message. With this implemented correctly you should be able to send a message from your AIM client. You can test this by connecting your client with using account and the Mac iChat client (in the Applications folder) with another account.
MyAIMListener class to the AIMConnection and implement the handleMessage method so that messages directed from the buddy that you are chatting with are displayed.
Part 2: Buddy Management
In this part of the assignment you will build a GUI for managing buddies and initiating conversations with them. The following steps provide a good outline for how to attack this part of the assignment:
BuddyList class.
BuddyListGUI class. Again, don't worry about handing events until you have created the GUI and it displays the way you would like. There is a main method provided for testing purposes that will display the GUI if you run this class. The buddy list should be a JComboBox.
BuddyListGUI is constructed.
AIMRunner class so that it displays the BuddyListGUI instead of a chat window.
Submitting your solution
Turn in your solution by committing the 132Labs project to the SVN server. Information about how to turn in your completed project to the SVN server can be found under Turning in the Labs Project to the SVN Repository in the How-To Document for the course.
Bonus Features
Each of the following features may be implemented for extra credit. These features must be implemented in order. All implemented features must be documented using JavaDoc comments. Note that some of these features will require you to learn additional Java on your own.
AIMSender and AIMListener interfaces to get some ideas about what is possible. Include a text file in your submission that describes each additional feature that you have added. (+1 for each additional correctly functioning feature).
Acknowledgements
This lab was inspired by a presentation by Tom Murtagh of Williams College in the Nifty Assignments Panel at SIGCSE 2010. Tom's assignment can be found in the Nifty Assignments repository.