/*
 * QuitWindow.java
 *
 * Created on 1. duben 2009, 15:08
 */

package base;

import base.*;

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


/**
 *
 * @author  illi
 */
public class XQuitFrame extends javax.swing.JDialog {

    /** Creates new form QuitWindow */
    public XQuitFrame() {
        initComponents();
        QuitFrameButtonOK.registerKeyboardAction(
        new DefaultAction((AbstractButton) QuitFrameButtonOK),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false),
            JComponent.WHEN_IN_FOCUSED_WINDOW);
        QuitFrameButtonCancel.registerKeyboardAction(
        new DefaultAction((AbstractButton) QuitFrameButtonCancel),
            KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false),
            JComponent.WHEN_IN_FOCUSED_WINDOW);
    }

    /** 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() {

        QuitFrameLabel1 = new javax.swing.JLabel();
        QuitFrameButtonOK = new javax.swing.JButton();
        QuitFrameButtonCancel = new javax.swing.JButton();
        QuitFrameLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Quit?");
        setAlwaysOnTop(true);
        setMinimumSize(new java.awt.Dimension(200, 110));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        QuitFrameLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        QuitFrameLabel1.setText("All unsaved changes will be lost.");
        QuitFrameLabel1.setName("QuitFrameLabel1"); // NOI18N

        QuitFrameButtonOK.setText("OK");
        QuitFrameButtonOK.setMaximumSize(new java.awt.Dimension(80, 25));
        QuitFrameButtonOK.setMinimumSize(new java.awt.Dimension(80, 25));
        QuitFrameButtonOK.setName("QuitFrameButtonOK"); // NOI18N
        QuitFrameButtonOK.setPreferredSize(new java.awt.Dimension(80, 25));
        QuitFrameButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                QuitFrameButtonOKActionPerformed(evt);
            }
        });

        QuitFrameButtonCancel.setText("Cancel");
        QuitFrameButtonCancel.setMaximumSize(new java.awt.Dimension(80, 25));
        QuitFrameButtonCancel.setMinimumSize(new java.awt.Dimension(80, 25));
        QuitFrameButtonCancel.setName("QuitFrameButtonCancel"); // NOI18N
        QuitFrameButtonCancel.setPreferredSize(new java.awt.Dimension(80, 25));
        QuitFrameButtonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                QuitFrameButtonCancelActionPerformed(evt);
            }
        });

        QuitFrameLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        QuitFrameLabel2.setText("Do you really want to quit?");
        QuitFrameLabel2.setName("QuitFrameLabel2"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(QuitFrameLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(QuitFrameButtonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(QuitFrameButtonCancel, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE))
                    .addComponent(QuitFrameLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(QuitFrameLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(QuitFrameLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(QuitFrameButtonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(QuitFrameButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void QuitFrameButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QuitFrameButtonOKActionPerformed
    this.setVisible(false);
    MainWindow.EnableMainWindow();
    MainWindow.QuitApplication();
}//GEN-LAST:event_QuitFrameButtonOKActionPerformed

private void QuitFrameButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QuitFrameButtonCancelActionPerformed
    this.setVisible(false);
    MainWindow.EnableMainWindow();
}//GEN-LAST:event_QuitFrameButtonCancelActionPerformed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
    this.setVisible(false);
    MainWindow.EnableMainWindow();
}//GEN-LAST:event_formWindowClosing



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton QuitFrameButtonCancel;
    private static javax.swing.JButton QuitFrameButtonOK;
    private static javax.swing.JLabel QuitFrameLabel1;
    private static javax.swing.JLabel QuitFrameLabel2;
    // End of variables declaration//GEN-END:variables

}
