import java.awt.*;
import java.awt.event.*;
import java.sql.*;

// This appears in Core Web Programming from
// Prentice Hall Publishers, and may be freely used
// or adapted. 1997 Marty Hall, hall@apl.jhu.edu.

/** Lets you view <B>and</B> update tables. Java 1.1. */

public class UpdateTable extends ShowTable {
  public static void main(String[] args) {
    new UpdateTable("UpdateTable");
  }

  private Button updateButton;

  /** Add a button to previous panel. */
  
  public UpdateTable(String title) {
    super(title);
    invalidate();
    updateButton = new Button("Update");
    updateButton.addActionListener(this);
    inputPanel.add(updateButton);
    pack();
    validate();
  }

  /** When Update button clicked, pop up a separate
   *  UpdateFrame that lets user enter fields and
   *  send results to the database.
   */
  
  public void actionPerformed(ActionEvent event) {
    if (event.getSource() == updateButton) {
      String tableName =
        tableField.getTextField().getText();
      new UpdateFrame(connection, metaData, tableName);
    } else
      super.actionPerformed(event);
  }
}

