import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * A basic JFC 1.1 based application.
 */
public class WelcomeFrame extends javax.swing.JFrame
{
	public WelcomeFrame()
	{
		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		//{{INIT_CONTROLS
		setTitle("Sun Management Center 3.0 Patch Installer");
		setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
		getContentPane().setLayout(new BorderLayout(0,0));
		setSize(488,370);
		setVisible(false);
		MainPanel.setLayout(new BorderLayout(0,0));
		getContentPane().add(BorderLayout.CENTER, MainPanel);
		NorthPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		MainPanel.add(BorderLayout.NORTH, NorthPanel);
		NorthPanel.setBackground(new java.awt.Color(204,204,204));
		WestPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		MainPanel.add(BorderLayout.WEST, WestPanel);
		WestPanel.setBackground(new java.awt.Color(204,204,204));
		ImageButton.setBorderPainted(false);
		WestPanel.add(ImageButton);
		SouthPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		MainPanel.add(BorderLayout.SOUTH,SouthPanel);
		SouthPanel.setBackground(new java.awt.Color(204,204,204));
		InstallButton.setText("Install");
		InstallButton.setActionCommand("Next");
		SouthPanel.add(InstallButton);
		ExitButton.setText("  Exit  ");
		ExitButton.setActionCommand("Exit");
		SouthPanel.add(ExitButton);
		EastPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		MainPanel.add(BorderLayout.EAST, EastPanel);
		EastPanel.setBackground(new java.awt.Color(204,204,204));
		CenterPanel.setLayout(new GridLayout(3,1,0,0));
		MainPanel.add(BorderLayout.CENTER, CenterPanel);
		CenterPanel.setBackground(new java.awt.Color(204,204,204));
		CenterPanel1.setLayout(new BorderLayout(0,0));
		CenterPanel.add(CenterPanel1);
		JTextArea1.setText("Welcome to SunMC3.0 Patch Installer");
		JTextArea1.setLineWrap(true);
		JTextArea1.setEditable(false);
		CenterPanel1.add(BorderLayout.CENTER,JTextArea1);
		JTextArea1.setBackground(new java.awt.Color(204,204,204));
		JTextArea1.setFont(new Font("Dialog", Font.BOLD, 12));
		CenterPanel2.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		CenterPanel.add(CenterPanel2);
		CenterPanel3.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		CenterPanel.add(CenterPanel3);
		InstallProgressBar.setStringPainted(true);
		CenterPanel3.add(InstallProgressBar);
		ImageButton.setIcon(imageIcon1);
		//}}

		//{{INIT_MENUS
		//}}

		//{{REGISTER_LISTENERS
		SymWindow aSymWindow = new SymWindow();
		this.addWindowListener(aSymWindow);
		SymAction lSymAction = new SymAction();
		InstallButton.addActionListener(lSymAction);
		ExitButton.addActionListener(lSymAction);
		//}}
	}

    /**
     * Creates a new instance of JFrame1 with the given title.
     * @param sTitle the title for the new frame.
     * @see #JFrame1()
     */
	public WelcomeFrame(String sTitle)
	{
		this();
		setTitle(sTitle);
	}
	
    /**
     * Notifies this component that it has been added to a container
     * This method should be called by <code>Container.add</code>, and 
     * not by user code directly.
     * Overridden here to adjust the size of the frame if needed.
     * @see java.awt.Container#removeNotify
     */
	public void addNotify()
	{
		// Record the size of the window prior to calling parents addNotify.
		Dimension size = getSize();
		
		super.addNotify();
		
		if (frameSizeAdjusted)
			return;
		frameSizeAdjusted = true;
		
		// Adjust size of frame according to the insets and menu bar
		javax.swing.JMenuBar menuBar = getRootPane().getJMenuBar();
		int menuBarHeight = 0;
		if (menuBar != null)
		    menuBarHeight = menuBar.getPreferredSize().height;
		Insets insets = getInsets();
		setSize(insets.left + insets.right + size.width, insets.top + insets.bottom + size.height + menuBarHeight);
	}

	// Used by addNotify
	boolean frameSizeAdjusted = false;

	//{{DECLARE_CONTROLS
	javax.swing.JPanel MainPanel = new javax.swing.JPanel();
	javax.swing.JPanel NorthPanel = new javax.swing.JPanel();
	javax.swing.JPanel WestPanel = new javax.swing.JPanel();
	javax.swing.JButton ImageButton = new javax.swing.JButton();
	javax.swing.JPanel SouthPanel = new javax.swing.JPanel();
	javax.swing.JButton InstallButton = new javax.swing.JButton();
	javax.swing.JButton ExitButton = new javax.swing.JButton();
	javax.swing.JPanel EastPanel = new javax.swing.JPanel();
	javax.swing.JPanel CenterPanel = new javax.swing.JPanel();
	javax.swing.JPanel CenterPanel1 = new javax.swing.JPanel();
	javax.swing.JTextArea JTextArea1 = new javax.swing.JTextArea();
	javax.swing.JPanel CenterPanel2 = new javax.swing.JPanel();
	javax.swing.JPanel CenterPanel3 = new javax.swing.JPanel();
	javax.swing.JProgressBar InstallProgressBar = new javax.swing.JProgressBar();
    javax.swing.ImageIcon imageIcon1 = new javax.swing.ImageIcon("images/sunmcInstall.gif");
	String exitMessage = "Exit Patch Installer?";
	//}}

	//{{DECLARE_MENUS
	//}}

	void setExitMessage(String exit){
	   exitMessage = exit;
    }

	void exitApplication()
	{
		try {
	    	// Beep
	    	Toolkit.getDefaultToolkit().beep();
	    	// Show a confirmation dialog
	    	int reply = JOptionPane.showConfirmDialog(this, 
	    	                                          exitMessage, 
	    	                                          "Exit?" , 
	    	                                          JOptionPane.YES_NO_OPTION, 
	    	                                          JOptionPane.QUESTION_MESSAGE);
			// If the confirmation was affirmative, handle exiting.
			if (reply == JOptionPane.YES_OPTION)
			{
		    	this.setVisible(false);    // hide the Frame
		    	this.dispose();            // free the system resources
		    	System.exit(0);            // close the application
			}
		} catch (Exception e) {
		}
	}

	class SymWindow extends java.awt.event.WindowAdapter
	{
		public void windowClosing(java.awt.event.WindowEvent event)
		{
			Object object = event.getSource();
			if (object == WelcomeFrame.this)
				WelcomeFrame_windowClosing(event);
		}
	}

	void WelcomeFrame_windowClosing(java.awt.event.WindowEvent event)
	{
		// to do: code goes here.
			 
		WelcomeFrame_windowClosing_Interaction1();
	}

	void WelcomeFrame_windowClosing_Interaction1() {
		try {
			this.exitApplication();
		} catch (Exception e) {
		}
	}

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == InstallButton)
				InstallButton_actionPerformed(event);
			else if (object == ExitButton)
				ExitButton_actionPerformed(event);
			
			
		}
	}

	void InstallButton_actionPerformed(java.awt.event.ActionEvent event)
	{
		// to do: code goes here.
	}

	void ExitButton_actionPerformed(java.awt.event.ActionEvent event)
	{
        WelcomeFrame_windowClosing_Interaction1();
    }

}
