package utilities;

import java.awt.Color;
import javax.swing.*;

    /** A containing frame for formatting Components.
     *  A Quit button appears at the bottom of the frame.
     */
public class ComponentFrame extends JFrame {
        /** Create a frame with the given title.
         */
    public ComponentFrame(String title){
        super(title);
        final int width = 300, height = 125;
        setSize(width,height);
        setBackground(Color.white);

        getContentPane().add(new QuitJPanel(),"South");
        addWindowListener(new WindowCloser());
        setVisible(true);
    }

        /** Add comp to the frame.
         */
    public void addComponent(JComponent comp){
        getComponentPanel().add(comp);
    }

    protected JPanel getComponentPanel(){
        return componentPanel;
    }

    // Storage for the components.
    private final JPanel componentPanel = new JPanel();
    {
        BoxLayout layout = new BoxLayout(componentPanel,BoxLayout.X_AXIS);
        componentPanel.setLayout(layout);
        componentPanel.setBackground(Color.white);
        // Components are displayed in the central area.
        getContentPane().add(componentPanel,"Center");
    }
}
