import java.awt.*; import java.io.File; /** * Provides images for the Gmail system. * * @version 1.0 of 10/10/99 * @author Gail Bonath * @author Joe Pipkins * @author Minna Mahlab * @author Kate Ducey */ public class Photo { // +--------+-------------------------------------- // | Fields | // +--------+ /** * The username of the person in the picture */ protected String username; /** * The jpeg file of the picture */ protected Image picture; // +--------------+-------------------------------- // | Constructors | // +--------------+ public Photo(String sender) { this.username = sender; try { this.picture = this.getPhoto(sender); } //try catch (Exception e) { } //catch(Exception) } //Photo(String) // +---------+--------------------------------------- // | Methods | // +---------+ /** * Takes in the username and returns the associated * Image from database folder. If there * is no associated Image file for the username, an * exception is thrown. */ public Image getPhoto(String username) throws Exception { String location = "/home/usr/photo/" + username + ".jpeg"; File file = new File(location); if (file.exists()) { return Toolkit.getDefaultToolkit().getImage(location); } // if else throw new Exception(username + " does not have a photo."); } //getPhoto(String) /** * Takes in a username and an Image and saves the * Image file in the database folder under the name * "username.jpeg". If there is already a * username.jpeg file in the folder, it will be * overwritten. */ public void setPhoto(String username, Image picture) { } //stub /** * Creates a window which displays the picture field */ public void displayPhoto() { } //stub } // Photo