O'Reilly logo

Java™ After Hours: 10 Projects You'll Never Do at Work by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Intercom 2

As with Intercom 1, the first item of business in Intercom 2 is to create its window, which you see in Figure 9.2. Here's how the code does it—note in particular the Connect button, which Intercom 1 (the server) doesn't have:

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

class Intercom2 extends Frame implements Runnable, ActionListener
{
    private Button button1, button2;
					private TextArea textarea1, textarea2;
					private TextField textfield1;
					private Label label1, label2, label3;
					public static void main(String[] args)
					{
					new Intercom2();
					}
					public Intercom2()
					{
					setLayout(null);
					label1 = new Label("Server IP address:");
					label1.setBounds(35, 80, 105, 20);
					add(label1);
					textfield1 = new TextField("127.0.0.1");
					textfield1.setBounds(145, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required