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:
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.
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
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
AIMConnectionclass provides a functioning implementation of this interface. You will be using an instance of
AIMConnectionto sign on/off and to send messages. The important methods in the
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
handleMessagemethod in the
AIMListenerwill be invoked when a message arrives from someone else. See the description of the
AIMBuddy findBuddy(String name): Get an
AIMBuddyobject representing an AIM user with the specified name. An
AIMBuddyobject 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
AIMAdapterclass provides a stub implementation of this interface in which all of the methods are empty. You will need to create a class that extends
AIMAdapterin order to handle incoming messages from other users. The most important method in the
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
AIMBuddyobject. The relevant method is:
String getName(): Returns the name of the buddy.
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
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:
AIMRunnerclass. It creates an instance of the
AIMConnectionclass and attempts to sign on. If the sign on is successful, it then creates and instance of the
AIMChatWindowclass and displays it.
AIMRunnerclass so that it uses the usernames and passwords of the AIM accounts that you created.
AIMChatWindowclass. The large text area should be a
JTextAreacomponent, the message box should be a
JTextFieldobject. You should get the GUI to display correctly before attempting to handle any events.
ActionListenerto 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.
MyAIMListenerclass to the
AIMConnectionand implement the
handleMessagemethod 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:
BuddyListGUIclass. Again, don't worry about handing events until you have created the GUI and it displays the way you would like. There is a
mainmethod provided for testing purposes that will display the GUI if you run this class. The buddy list should be a
AIMRunnerclass so that it displays the
BuddyListGUIinstead 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.
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.
AIMListenerinterfaces 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).
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.