Creating Intercom 1

The first thing to do in Intercom 1 is to create the window and controls you see in Figure 9.1. This works by creating a new object of the Intercom1 class in the main method:

import java.awt.*;
import java.awt.event.*;

public class Intercom1 extends Frame implements Runnable, ActionListener
{

    public static void main(String[] args)
					{
					new Intercom1();
					}
    .
    .
    .
}

Next, the code adds the Send button, connects it to an ActionListener, and adds the top text area control (note that the text area controls in this project have only vertical scrollbars so that the user doesn't have to stop to scroll horizontally with the mouse each time long text appears or he's typing something longer than the text area can display on one line):

Get Java™ After Hours: 10 Projects You'll Never Do at Work now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.