/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AboutBox.java
 *
 * Created on Oct 13, 2010, 12:31:35 PM
 */

package MicrochipMPFS;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.Action;

public class AboutBox extends javax.swing.JDialog {
    ImageIcon icon = new ImageIcon(getClass().getResource("/Resource/mchpIcon.png"));
    /** Creates new form AboutBox */
    public AboutBox(javax.swing.JFrame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        //setIconImage(icon.getImage());
        setIconImage(parent.getIconImage());
        icon = new ImageIcon(getClass().getResource("/Resource/mchp.png"));
        lblImage.setIcon(icon);

        AboutBoxKeyEventActionIntialization();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblToolName = new javax.swing.JLabel();
        lblVersion = new javax.swing.JLabel();
        lblCopyRight = new javax.swing.JLabel();
        lblCompany = new javax.swing.JLabel();
        btnOK = new javax.swing.JButton();
        lblImage = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textAreaMPFSTool = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("About : MPFS 2.2");
        setLocationByPlatform(true);
        setModal(true);
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblToolName.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 11)); // NOI18N
        lblToolName.setText("Microchip MPFS Generator");
        getContentPane().add(lblToolName, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 5, 270, 20));

        lblVersion.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 12));
        lblVersion.setText("Version 2.2");
        getContentPane().add(lblVersion, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 25, 220, 10));

        lblCopyRight.setText("Copyright © 2010 Microchip Technology, Inc.");
        getContentPane().add(lblCopyRight, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 40, 270, -1));

        lblCompany.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 12));
        lblCompany.setText("Microchip");
        getContentPane().add(lblCompany, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 55, 120, -1));

        btnOK.setText("OK");
        btnOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOKActionPerformed(evt);
            }
        });
        getContentPane().add(btnOK, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 147, 90, 20));

        lblImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resource/mchp.png"))); // NOI18N
        lblImage.setText("jLabel5");
        getContentPane().add(lblImage, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 130, 170));

        textAreaMPFSTool.setColumns(20);
        textAreaMPFSTool.setEditable(false);
        textAreaMPFSTool.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 12));
        textAreaMPFSTool.setRows(5);
        textAreaMPFSTool.setText("This software and source code is distributed \nunder the license provided with the Microchip\nTCP/IP Stack. For additional help, please \nrefer to the Microchip TCP/IP Stack Help file.");
        jScrollPane1.setViewportView(textAreaMPFSTool);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 70, 280, 70));

        pack();
    }// </editor-fold>//GEN-END:initComponents
/*
    private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnOKActionPerformed
 */
 private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            dispose();
    }
     
    private void AboutBoxKeyEventActionIntialization()
    {
        Action  ESCactionListener = new AbstractAction () {
          public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
            dispose();
          }
        };
        KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true);
        JComponent comp = this.getRootPane();
        comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "ESCAPE");
        ActionMap actionMap = comp.getActionMap();
        actionMap.put("ESCAPE", ESCactionListener);

        /* OK button Action Solves MAC , Linux and Window enter key issue*/
        Action  OKactionListener = new AbstractAction () {
          public void actionPerformed(ActionEvent actionEvent) {
            btnOKActionPerformed(actionEvent);
          }
        };

        KeyStroke enter_ok = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
        btnOK.getInputMap(JButton.WHEN_FOCUSED).put(enter_ok, "OK");
        actionMap = btnOK.getActionMap();
        actionMap.put("OK", OKactionListener);
        btnOK.setActionMap(actionMap);
    }
    /**
    * @param args the command line arguments
    */
    /*
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                AboutBox dialog = new AboutBox(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnOK;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblCompany;
    private javax.swing.JLabel lblCopyRight;
    private javax.swing.JLabel lblImage;
    private javax.swing.JLabel lblToolName;
    private javax.swing.JLabel lblVersion;
    private javax.swing.JTextArea textAreaMPFSTool;
    // End of variables declaration//GEN-END:variables

}
