package javakurs.uebung06;

import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;

/**
 * {@link FridgeContentTable} provides a GUI (JFrame) that displays
 * contents of the fridge in JTable.
 *
 * @author Ulrich Schaefer, DFKI
 * @version $Id$
 */

public class FridgeContentTable
    extends JFrame {

  /**
   * This creates a new instance of {@link FridgeContentTable}.
   *
   * @param model
   *          the table moddel
   */
  public FridgeContentTable(AbstractTableModel model) {

    super("K\u00fchlschrank-Inhaltsanzeige");
    JTable table = new JTable(model);
    Container cp = getContentPane();
    // add title text
    cp.add(
      new JLabel("Der K\u00fchlschrank enth\u00e4lt:"), BorderLayout.NORTH);
    // add JTable and scroll bar
    cp.add(new JScrollPane(table), BorderLayout.CENTER);
    setSize(240, 320);
    setVisible(true);
    // keep window always on top
    this.setAlwaysOnTop(true);
  }
}
