/*
 * @(#) UIMainFrame.java  1.10 10/09/02
 *
 * Copyright ***,  All Rights Reserved.
 * 
 * This software is the proprietary information of ********  
 * Use is subject to license terms.
 * 
 */

// import java packages
//
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import javax.swing.event.*;
import javax.swing.AbstractButton.*;
import java.util.*;
import java.io.*;


/**
 * This class is to display the symbol list for a certain level
 */
public class UIMessageDialog extends JDialog implements ActionListener{

    //-----------------------------------------------------------------
    //
    // static data members
    //
    //-----------------------------------------------------------------

    //-----------------------------------------------------------------
    //
    // instance data members
    //
    //-----------------------------------------------------------------

    // the main panel
    //
    JPanel jMainPane = new JPanel();

    // four panels on the main pane
    //
    JPanel jTitlePane = new JPanel();
    JPanel jMiddlePane = new JPanel();
    JPanel jBottomPane = new JPanel();

    // components on the top pane
    //
    JLabel jTitleName = new JLabel();
    JTextArea jTextMessage = new JTextArea(6, 256);

    JButton jButtonOK = new JButton();
    JButton jButtonCancel = new JButton();

    // components on the bottom pane
    //
    GridBagLayout gridBagLayout1 = new GridBagLayout();

    // borders
    //
    Border border2;  
    Border border3;

    /**
     * default class constructor
     *
     * @param frame the Frame from which the dialog is displayed
     * @param title the String to display in the dialog's title bar
     * @param message_a message to set to the text area
     * @param modal true for a modal dialog, false for one that allows other
     *  windows to be active at the same time 
     *
     */
    public UIMessageDialog(Frame frame, String title, String message_a, boolean modal) {
	super(frame, title, modal);
	jTitleName.setText(title);
	jTextMessage.setText(message_a);
	jbInit();
	pack();
    }

    private void jbInit() {

	// add the main panel
	//
	jMainPane.setPreferredSize(new Dimension(450, 200));
	jMainPane.setLayout(gridBagLayout1);

	jTitlePane.setPreferredSize(new Dimension(400, 30));
	jBottomPane.setPreferredSize(new Dimension(400, 30));
	
	// add four panels
	//
	jMainPane.add(jTitlePane, 
		      new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
					     GridBagConstraints.CENTER, 
					     GridBagConstraints.HORIZONTAL, 
					     new Insets(5, 5, 5, 5), 0, 0));

	jMainPane.add(jMiddlePane, 
		      new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
					     GridBagConstraints.CENTER, 
					     GridBagConstraints.BOTH, 
					     new Insets(5, 5, 5, 5), 0, 0));

	jMainPane.add(jBottomPane, 
		      new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
					     GridBagConstraints.CENTER, 
					     GridBagConstraints.HORIZONTAL, 
					     new Insets(5, 5, 5, 5), 0, 0));

	// add components on top panel
	//
	jTitleName.setPreferredSize(new Dimension(120, 20));
	jTitlePane.setLayout(new FlowLayout(FlowLayout.LEFT));
	jTitlePane.add(jTitleName);


	// add components on top panel
	//
	jMiddlePane.setLayout(new FlowLayout(FlowLayout.CENTER));
	//jTextMessage.setPreferredSize(new Dimension(400, 1000));
	JScrollPane jMessagePane = 
	    new JScrollPane(jTextMessage,
			    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	//new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
	//		    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
	//jMessagePane.getViewport().add(jTextMessage);
	//jMessagePane.setPreferredSize(new Dimension(400, 400));
	jMiddlePane.setPreferredSize(new Dimension(400, 100));
	jMessagePane.setPreferredSize(jMiddlePane.getPreferredSize());
	jMiddlePane.add(jMessagePane);
	//jMessagePane.setPreferredSize(jMiddlePane.getPreferredSize());
	jTextMessage.revalidate();

	// add components on the check panel
	//
	jBottomPane.setLayout(new FlowLayout(FlowLayout.CENTER));

	jButtonOK.setText("OK");
	jBottomPane.add(jButtonOK);
	jButtonOK.setPreferredSize(new Dimension(80, 24));
	jButtonOK.addActionListener(this);

	// add the main pain
	//
	getContentPane().add(jMainPane);
	jMiddlePane.revalidate();
    }

    /**
     * handle the event when a button is clicked
     * 
     * @param e the button event
     */
    public void actionPerformed(ActionEvent e) {
	
	if(e.getSource() == jButtonOK) {
	    dispose();
	}
    }
}
