import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

public class HistoryPanel extends JPanel {
  private static JTextArea historyDisplay = new JTextArea();
  private JButton clearButton = new JButton("Clear History");
  
  public HistoryPanel() {
   
   JPanel copyPanel = new JPanel();
   copyPanel.setLayout(new FlowLayout());
   copyPanel.add(clearButton);
    clearButton.addActionListener(new ClearButtonListener());
    
    historyDisplay.setEditable(true);
    historyDisplay.setLineWrap(true);
    historyDisplay.setWrapStyleWord(true);
    JScrollPane sPane = new JScrollPane(historyDisplay);
    
    setLayout(new BorderLayout());
    
    add (sPane, BorderLayout.CENTER); 
    add (copyPanel, BorderLayout.SOUTH);
  }
  
  public static void setText(String s)
  {
    historyDisplay.append(s);
  }
  
   private class ClearButtonListener implements ActionListener {
    public void actionPerformed (ActionEvent e){
      historyDisplay.setText(null);
    }
  }
}