import java.awt.*; import java.awt.event.*; /** * * * * * * * * @author Ashfaqur Rahman * @author Jared Baszler * @author Mike Yohay * @author Prashant Paroda * @version 1.0 of October 1999 */ public class Gmail extends WindowAdapter implements ActionListener { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** The frame used for interaction. */ protected Frame login; protected Frame inbox; /** The field in which the user enters a name. */ protected TextField userName; /** The field in which the password is entered. */ protected TextField password; /** The button the user presses. */ protected Button trashButton, loginButton, outboxButton, inboxButton; /** The area used for output. */ protected Label out, out1, out2, out3, out4; /** The area used for output. */ // +--------------+-------------------------------------------- // | Constructors | // +--------------+ /** Set up the frame for interaction. */ protected Gmail() { // Create the frame (the window). login = new Frame("GMAIL"); login.setLayout(new GridLayout(25,50)); login.addWindowListener(this); // Create the entry field. Initialized to have a number of // spaces so that there is room for the user to enter a name. userName = new TextField(10); password = new TextField(15); // Create the button. loginButton = new Button("Login"); loginButton.addActionListener(this); // Create the output field. Right now, we'll use it for // instructions. out = new Label("Enter your Username and Password"); out1 = new Label(); out2 = new Label("Username"); out3 = new Label("Password"); out4 = new Label("Welcome to GMAIL"); // Add the components to the interface. login.add(out4); login.add(out); login.add(out2); login.add(userName); login.add(out1); login.add(out3); login.add(password); login.add(loginButton); login.pack(); // And we're ready to go. login.show(); } // GreetGUI() // +---------+---------------------------------------------- // | Methods | // +---------+ public void Inbox() { inbox = new Frame("Inbox"); inbox.setLayout(new GridLayout()); inbox.addWindowListener(this); } // Inbox() // +----------------+------------------------------------------ // | Event Handlers | // +----------------+ /** React to a click on the button. */ public void actionPerformed(ActionEvent evt) { // Update the output out.setText("Welcome " + userName.getText() + " to GMail."); login.remove(userName); login.remove(password); login.remove(loginButton); login.remove(out2); login.remove(out3); login.remove(out4); trashButton = new Button("Trash"); outboxButton = new Button("Outbox"); inboxButton = new Button("Inbox"); login.add(trashButton); login.add(outboxButton); login.add(inboxButton); login.pack(); } // actionPerformed(ActionEvent) /** React to the closing of the window. */ public void windowClosing(WindowEvent event) { login.dispose(); System.exit(0); } // windowClosing() // +------+---------------------------------------------------- // | Main | // +------+ /* Start the ball rolling by creating an object. */ public static void main(String[] args) { new Gmail(); } // main(String[]) } // class GreetGUI