/**
 * ExceptionReportGUI.java
 * @date Jan 15, 2011
 * @author ricky barrette
 * @author Twenty Codes, LLC
 */
package com.TwentyCodes.java.OrderProcessor.UI;

import java.awt.BorderLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 * this simple frame will be used to display exception reports to the user
 * @author ricky barrette
 */
public class ExceptionReportGUI extends JFrame implements ActionListener {

	private static final long serialVersionUID = -4203182071311606914L;

	/**
	 * Creates a new ExceptionReportGUI
	 * @throws HeadlessException
	 * @author ricky barrette
	 */
	public ExceptionReportGUI(String report) {
		super();
		setTitle("We're Sorry....");
		setIconImage(new ImageIcon(getClass().getResource("/info.png")).getImage());
		
		JButton ok = new JButton("Ok", new ImageIcon(getClass().getResource("/accept.png")));
		ok.addActionListener(this);
		
		JScrollPane scrollPane = new JScrollPane();
		
		final JTextArea results = new JTextArea();
		scrollPane.setViewportView(results);
		
		results.setEditable(false);
		results.setText(report);
		
		this.getContentPane().add(scrollPane, BorderLayout.CENTER);
		this.getContentPane().add(ok, BorderLayout.SOUTH);
		pack();
		setVisible(true);
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		this.dispose();	
	}

}