/*  File: TestFrame.java
    Author: Brent Nelson, Anthony Slade
    Date: 08 August, 2001
    Description:
        A simple GUI element which displays a single value in a label component.
	Used in demonstration of Observables interface.
*/

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;

public class TestFrame extends JFrame {

  JLabel labelText, labelValue;

  /** Creates a frame that contains a panel with two labels.  One of
   * the labels is the output value from the TestSimCallback cell. */
  public TestFrame() {
    super( "TestFrame" );

    JPanel contents = (JPanel)getContentPane();
    contents.setLayout( new BorderLayout() );

    labelText  = new JLabel("Count Value:");
    labelValue = new JLabel("Uninitialized...");

    //Add labels to the JPanel.
    contents.add(labelText, BorderLayout.NORTH);
    contents.add(labelValue, BorderLayout.CENTER);

    pack();
    setVisible( true );
  }

  /** Change label text to reflect parameter value.
   * @param cnt the current count of the TestSimCallback output */
  public void updateValues(int cnt) {
    labelValue.setText(""+cnt);
  }

  /** Just builds a frame to test this class only */
  public static void main(String[] args) {
    JFrame frame = new TestFrame();
    frame.addWindowListener(new WindowAdapter() {
	public void windowClosing(WindowEvent e) {
	  System.exit(0);
	}
      });
  }
}

