package com.wiverson.macosbook.plugin;
import javax.swing.JDialog;
import javax.swing.JFrame;
import java.awt.Frame;
public class QuitConfirmJDialog extends JDialog
{
/** Creates new form QuitConfirmJDialog */
public QuitConfirmJDialog(Frame parent, boolean modal)
{
super(parent, modal);
initComponents();
}
/** 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.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
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);
}//GEN-END:initComponents
private void formFocusHandler(java.awt.event.FocusEvent evt)//GEN-FIRST:event_formFocusHandler
{//GEN-HEADEREND:event_formFocusHandler
okButton.requestFocus();
}//GEN-LAST:event_formFocusHandler
private void cancelButtonHandler(java.awt.event.ActionEvent evt)//GEN-FIRST:event_cancelButtonHandler
{//GEN-HEADEREND:event_cancelButtonHandler
okButton.requestFocus();
this.hide();
}//GEN-LAST:event_cancelButtonHandler
private void okButtonHandler(java.awt.event.ActionEvent evt)//GEN-FIRST:event_okButtonHandler
{//GEN-HEADEREND:event_okButtonHandler
System.exit(0);
}//GEN-LAST:event_okButtonHandler
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt)
{//GEN-FIRST:event_closeDialog
this.hide();
}//GEN-LAST:event_closeDialog
public static void main(String args[])
{
new QuitConfirmJDialog(new JFrame(), false).show();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
|