/* InputDialog.java */ package ciips.animation; import java.awt.*; import java.lang.*; import java.awt.event.*; /** * An InputCompleteListener expects to be sent an InputEvent containing * a String and a reference to the source of the input */ public class InputDialog extends Dialog implements ActionListener { private TextField tf; private InputCompleteListener listener; private static final boolean DEBUG = false; private AlgAnimFrame frame; public InputDialog( AlgAnimFrame f, String s ) { super( f, s ); if( DEBUG ) System.out.println("InputDialog - [" + s + "]" ); add( BorderLayout.NORTH, new Label( s ) ); tf = new TextField( 10 ); Button ok = new Button( "OK" ); ok.setBackground( Color.yellow ); add( BorderLayout.CENTER, tf ); add( BorderLayout.SOUTH, ok ); ok.addActionListener( this ); // listener = l; this.frame = f; validate(); pack(); } public void actionPerformed( ActionEvent e ) { String s = tf.getText(); listener = frame.getAlg(); if( DEBUG ) System.out.println("InputDialog:actPerf - [" + s + "]" ); InputDialogEvent input_event = new InputDialogEvent( this, s ); listener.inputComplete( input_event ); } public String toString() { return "InputDialog [" + getTitle() + "] listener " + listener.getClass(); } }