import java.awt.*;
import java.beans.*;

public class FredWin extends java.awt.Frame
{
	//{{DECLARE_CONTROLS
	java.awt.Label sezLbl = new java.awt.Label();
	java.awt.Button mysteryBtn = new java.awt.Button();
	java.awt.Label bannerLbl = new java.awt.Label();
	//}}
    
	public FredWin()
	{
		//{{INIT_CONTROLS
		setLayout(null);
		setBackground(new java.awt.Color(128,0,255));
		setFont(new Font("SansSerif", Font.PLAIN, 12));
		setSize(553,300);
		setVisible(false);
		sezLbl.setText("Shake your groove thang...");
		sezLbl.setAlignment(java.awt.Label.CENTER);
		add(sezLbl);
		sezLbl.setFont(new Font("MonoSpaced", Font.PLAIN, 22));
		sezLbl.setBounds(12,132,528,48);
		mysteryBtn.setLabel("Mystery Button");
		add(mysteryBtn);
		mysteryBtn.setBackground(java.awt.Color.magenta);
		mysteryBtn.setFont(new Font("Dialog", Font.BOLD, 12));
		mysteryBtn.setBounds(72,216,120,40);
		bannerLbl.setText("Fred sez...");
		bannerLbl.setAlignment(java.awt.Label.CENTER);
		add(bannerLbl);
		bannerLbl.setFont(new Font("Dialog", Font.BOLD, 60));
		bannerLbl.setBounds(12,12,444,96);
		setTitle("Fred Sez");
		//}}

		//{{REGISTER_LISTENERS
		FredWinAdapter fredWinAdapter = new FredWinAdapter();
		this.addWindowListener(fredWinAdapter);
		FredWinAction fredWinAction = new FredWinAction();
		mysteryBtn.addActionListener(fredWinAction);
		//}}
	} //0 arg constructor

	public FredWin(String title)
	{
		this();
		setTitle(title);
	} //1 arg constructor
	
	public void setSezLbl(String str)
	{
	    sezLbl.setText(str);
	    validate();
	} //setSezLbl
	
	
	//**********************************************************
	// Java Beans methods
	//
	public synchronized void show()
	{
		move(50, 50);
		super.show();
	}
	public void addNotify()
	{
		// Record the size of the window prior to calling parents addNotify.
		Dimension d = getSize();

		super.addNotify();

		if (fComponentsAdjusted)
			return;

		// Adjust components according to the insets
		setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
		Component components[] = getComponents();
		for (int i = 0; i < components.length; i++)
			{
			Point p = components[i].getLocation();
			p.translate(insets().left, insets().top);
			components[i].setLocation(p);
		}
		fComponentsAdjusted = true;
	}

	// Used for addNotify check.
	boolean fComponentsAdjusted = false;

	//**********************************************************
	// Event Handling methods
	//
	
	// window adapter
	class FredWinAdapter extends java.awt.event.WindowAdapter
	{
		public void windowClosing(java.awt.event.WindowEvent event)
		{
		Object object = event.getSource();
		if (object == FredWin.this)
			FredWin_WindowClosing(event);
		}
	} //FredWinAdapter
	
	void FredWin_WindowClosing(java.awt.event.WindowEvent event)
	{
		this.dispose();		 // dispose of the Frame.
	} //FredWin_WindowClosing

	// mystery button action listener
	class FredWinAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == mysteryBtn)
				mysteryBtn_ActionPerformed(event);
		} //actionPerformed
	} //FredWinAction

	void mysteryBtn_ActionPerformed(java.awt.event.ActionEvent event)
	{
		this.dispose();		 // dispose of the Frame.
	} //mysteryBtn_ActionPerformed
	//{{DECLARE_MENUS
	//}}
} //FredWin