/**
 *
 * @author Copyright (c) 2000 by BEA Systems, Inc. All Rights Reserved.
 */
package examples.applets.ping;

import java.awt.*;
import java.io.*;
import java.applet.*;
import java.util.*;

public abstract class TextApplet extends Applet {

    protected PrintStream console;
    protected TextArea ta;
    protected Panel buttonPanel;

    protected void addButton(Button b) {
	buttonPanel.add(b);
    }

    public TextApplet() {
	GridBagLayout gb = new GridBagLayout();
	setBackground(Color.white);
	setLayout(gb);
	GridBagConstraints gc = new GridBagConstraints();
	gc.insets = new Insets(10, 10, 10, 10);
	gc.fill = gc.NONE;

	ta = new TextArea("", 20, 45); // , TextArea.SCROLLBARS_BOTH);
	gc.anchor = gc.NORTH;
	gc.gridwidth = gc.REMAINDER;
	gb.setConstraints(ta, gc);
	add(ta);
	console = new TextOut(ta);

	gc.anchor = gc.CENTER;

	buttonPanel = new Panel();
	//	gc.gridheight = gc.REMAINDER;
	gc.gridwidth = gc.REMAINDER;
	gb.setConstraints(buttonPanel, gc);
	add(buttonPanel);
    }

    protected void stackTrace(Throwable t) {
	t.printStackTrace();
	if (console != null) {
	    t.printStackTrace(console);
	}
    }

    protected void p(String s) {
	System.out.println(s);
	if (console != null) {
	    console.println(s);
	}
    }

    public abstract boolean action(Event e, Object what);

    public abstract void init();

    public abstract void start();

    public abstract void stop();
}

	    

