June 2005
Beginner to intermediate
336 pages
6h 29m
English
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, ...Read now
Unlock full access