/*
 * BIAboutDialog.java
 *
 * Copyright © 1994-2004, Oracle. All rights reserved. Oracle grants
 * you ("Licensee") a non-exclusive, royalty-free, worldwide license to use,
 * modify and redistribute this software in source and binary code form, provided
 * that (i) this copyright notice and license appear on all copies of the
 * software; (ii) Licensee does not utilize the software in a manner disparaging
 * to Oracle; and (iii) Licensee does not utilize the software in a manner that
 * violates the terms of any Licensee agreement with Oracle.
 */
package samples.javaclient;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;
import oracle.bali.ewt.olaf.OracleLookAndFeel;
import oracle.dss.util.gui.BIExceptionDialog;

/**
 * A Sample BI Beans About dialog
 * <P>
 * The BIAboutDialog is a simple dialog that displays the samples version information.
 *
 */
public class BIAboutDialog extends JDialog {

  /**
   * Constructor for BIDialog.
   *
   * @param frame The parent frame.
   * @param title The title of the JDialog.
   * @param modal Indicates whether the dialog should be modal.
   */
  public BIAboutDialog(Frame frame, String title, boolean modal) {
    super(frame, title, modal);

    // set the default look and feel to OracleLookAndFeel
    try {
      UIManager.setLookAndFeel(new OracleLookAndFeel());
    }
    catch (Exception landfex) {
      BIExceptionDialog exDlg = new BIExceptionDialog(this, landfex, getTitle(),
                                  landfex.getMessage(), null);
      exDlg.display();
      exDlg.dispose();
    }

    init();
  }

  /**
   * Initialize and construct contents of the BIAboutDialog.
   */
  protected void init() {
    // Create the top level panel with the copyright info.
    JPanel _topPanel = new JPanel();
    _topPanel.setBorder(new TitledBorder(""));
    _topPanel.setLayout(new FlowLayout());
    _topPanel.add(new JLabel("BI Beans Samples 9.0.5"));
    _topPanel.add(new JLabel("Copyright © 2003, Oracle Corporation"));
    _topPanel.add(new JLabel("All rights reserved"));

    // Add the bottom level dialog with the OK button that closes the dialog
    JPanel _bottomPanel = new JPanel();
    _bottomPanel.setLayout(new FlowLayout());

    JButton _ok = new JButton("OK");
    _ok.addActionListener( new ActionListener() {
      public void actionPerformed(ActionEvent event) {
        BIAboutDialog.this.setVisible(false);
      }
    });
    _bottomPanel.add(_ok);

    // Create the panel containing the top and bottom panel.
    JPanel _pane = new JPanel();
    _pane.add(_topPanel);
    _pane.add(_bottomPanel);

    // Add the panel to dialog.
    getContentPane().add(_pane);
  }
}
