import javax.swing.*;
import javax.swing.border.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ShapePanel extends JPanel implements ActionListener {
    private JButton lineButton = new JButton(ScribblePanel.LINE);
    private JButton ovalButton = new JButton(ScribblePanel.CIRCLE);
    private JButton squareButton = new JButton(ScribblePanel.SQUARE);
    ScribblePanel scribblePanel;
        

    public ShapePanel (ScribblePanel sp) {
        scribblePanel = sp;
        setLayout(new GridLayout(3, 1, 5, 30));
        //setBorder(BorderFactory.createEmptyBorder(40, 10, 40, 10));
        // put buttons on button panel and button panel on whole panel
        add(lineButton);
        add(ovalButton);
        add(squareButton);
                
                
        // add listeners for buttons
        lineButton.addActionListener(this);
        ovalButton.addActionListener(this);
        squareButton.addActionListener(this);

    }
        
        
    public void actionPerformed(ActionEvent e) {
        String command = e.getActionCommand();
        scribblePanel.setShape(command);
    }
}

