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, ...
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.