FileDocCategorySizeDatePackage
QuitConfirmJDialog.javaAPI DocExample4053Wed Jul 17 00:28:14 BST 2002com.wiverson.macosbook.plugin

QuitConfirmJDialog

public class QuitConfirmJDialog extends JDialog

Fields Summary
private JPanel
buttonPanel
private JButton
okButton
private JButton
cancelButton
private JLabel
jLabel1
Constructors Summary
public QuitConfirmJDialog(Frame parent, boolean modal)
Creates new form QuitConfirmJDialog

        super(parent, modal);
        initComponents();
    
Methods Summary
private voidcancelButtonHandler(java.awt.event.ActionEvent evt)

//GEN-HEADEREND:event_cancelButtonHandler
        okButton.requestFocus();
        this.hide();
    
private voidcloseDialog(java.awt.event.WindowEvent evt)
Closes the dialog

//GEN-FIRST:event_closeDialog
        this.hide();
    
private voidformFocusHandler(java.awt.event.FocusEvent evt)

//GEN-HEADEREND:event_formFocusHandler
        okButton.requestFocus();
    
private voidinitComponents()
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.

        buttonPanel = new javax.swing.JPanel();
        cancelButton = new javax.swing.JButton();
        okButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setTitle("Confirm Quit");
        setModal(true);
        setResizable(false);
        addFocusListener(new java.awt.event.FocusAdapter()
        {
            public void focusGained(java.awt.event.FocusEvent evt)
            {
                formFocusHandler(evt);
            }
        });

        addWindowListener(new java.awt.event.WindowAdapter()
        {
            public void windowClosing(java.awt.event.WindowEvent evt)
            {
                closeDialog(evt);
            }
        });

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                cancelButtonHandler(evt);
            }
        });

        buttonPanel.add(cancelButton);

        okButton.setText("OK");
        this.getRootPane().setDefaultButton(okButton);
        okButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                okButtonHandler(evt);
            }
        });

        buttonPanel.add(okButton);

        getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);

        jLabel1.setText("Are you sure you want to quit?");
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER);

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setSize(new java.awt.Dimension(366, 116));
        setLocation((screenSize.width-366)/2,(screenSize.height-116)/2);
    
public static voidmain(java.lang.String[] args)

        new QuitConfirmJDialog(new JFrame(), false).show();        
    
private voidokButtonHandler(java.awt.event.ActionEvent evt)

//GEN-HEADEREND:event_okButtonHandler
        System.exit(0);