// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   ErrorMessageBox.java

package lt.monarch.awt;

import java.awt.*;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

// Referenced classes of package lt.monarch.awt:
//			MessageBox

public class ErrorMessageBox extends MessageBox
{

	private static final String expandLabel = "Details >>";
	private static final String collapseLabel = "<< Details";
	private Button details;
	private TextArea label;
	private boolean expanded;

	public ErrorMessageBox(String s, Throwable throwable)
	{
		super("Error", s);
		GridBagLayout gridbaglayout = (GridBagLayout)getLayout();
		GridBagConstraints gridbagconstraints = new GridBagConstraints();
		try
		{
			ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
			PrintStream printstream = new PrintStream(bytearrayoutputstream);
			throwable.printStackTrace(printstream);
			byte abyte0[] = bytearrayoutputstream.toByteArray();
			String s1 = new String(abyte0, 0);
			label = new TextArea(s1, 10, 60);
			label.setEditable(false);
			label.setBackground(Color.white);
			label.setForeground(Color.red);
			gridbagconstraints.insets = new Insets(5, 5, 5, 5);
			gridbagconstraints.weightx = 1.0D;
			gridbagconstraints.weighty = 2D;
			gridbagconstraints.gridx = 0;
			gridbagconstraints.gridy = 2;
			gridbagconstraints.fill = 1;
			gridbagconstraints.gridwidth = 0;
			gridbaglayout.setConstraints(label, gridbagconstraints);
			add(label);
			expanded = false;
			details = new Button();
			gridbagconstraints.insets = new Insets(0, 0, 5, 5);
			gridbagconstraints.weightx = 0.0D;
			gridbagconstraints.weighty = 0.0D;
			gridbagconstraints.gridx = 1;
			gridbagconstraints.gridy = 1;
			gridbagconstraints.fill = 2;
			gridbagconstraints.anchor = 11;
			gridbaglayout.setConstraints(details, gridbagconstraints);
			add(details);
			details.setLabel("Details >>");
		}
		catch(Throwable _ex) { }
		pack();
		remove(label);
		resize(size().width, size().height - label.size().height);
		centerOnScreen();
	}

	public boolean action(Event event, Object obj)
	{
		if(event.target == details && !expanded)
		{
			expanded = true;
			details.setLabel("<< Details");
			add(label);
			resize(size().width, size().height + label.preferredSize().height);
			validate();
			return true;
		}
		if(event.target == details && expanded)
		{
			expanded = false;
			details.setLabel("Details >>");
			remove(label);
			resize(size().width, size().height - label.size().height);
			validate();
			return true;
		} else
		{
			return super.action(event, obj);
		}
	}
}
