home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / Sharpdev / 099bsetup.exe / JavaOKDialog.xft < prev    next >
Extensible Markup Language  |  2003-09-21  |  4KB  |  123 lines

  1. <?xml version="1.0"?>
  2. <Template Originator="Gary Gray" Language="JAVA" Created="09/05/2001" LastModified="09/05/2001">
  3.     
  4.     <TemplateConfiguration>
  5.            <Name>${res:Templates.File.Java.JavaAWTOKDialog.Name}</Name>
  6.            <Icon>Java.File.Form</Icon>
  7.            <Category>Java</Category>
  8.            <LanguageName>Java</LanguageName>
  9.            <Description>${res:Templates.File.Java.JavaAWTOKDialog.Description}</Description>
  10.     </TemplateConfiguration>
  11.     
  12.     <TemplateFiles>
  13.            <File DefaultExtension=".java" DefaultName="OKDialog">
  14.  
  15. <![CDATA[
  16. /*
  17.  * OKDialog.java
  18.  *
  19.  * created on ${Date} at ${Time}
  20.  */
  21.  
  22. public class OKDialog extends javax.swing.JDialog {
  23.     /** A return status code - returned if Cancel button has been pressed */
  24.     public static final int RET_CANCEL = 0;
  25.     /** A return status code - returned if OK button has been pressed */
  26.     public static final int RET_OK = 1;
  27.  
  28.     /** Creates new form OKDialog */
  29.     public OKDialog(java.awt.Frame parent, boolean modal) {
  30.         super(parent, modal);
  31.         initComponents();
  32.     }
  33.  
  34.     /** return the return status of this dialog - one of RET_OK or RET_CANCEL */
  35.     public int getReturnStatus() {
  36.         return returnStatus;
  37.     }
  38.  
  39.     /** This method is called from within the constructor to
  40.      * initialize the form.
  41.      * WARNING: Do NOT modify this code. The content of this method is
  42.      * always regenerated by the Form Editor.
  43.      */
  44.     private void initComponents() {//GEN-BEGIN:initComponents
  45.         addWindowListener(new java.awt.event.WindowAdapter() {
  46.                               public void windowClosing(java.awt.event.WindowEvent evt) {
  47.                                   closeDialog(evt);
  48.                               }
  49.                           }
  50.                          );
  51.  
  52.         buttonPanel = new javax.swing.JPanel();
  53.         buttonPanel.setLayout(new java.awt.FlowLayout(2, 5, 5));
  54.  
  55.         okButton = new javax.swing.JButton();
  56.         okButton.setText("OK");
  57.         okButton.addActionListener(new java.awt.event.ActionListener() {
  58.                                        public void actionPerformed(java.awt.event.ActionEvent evt) {
  59.                                            okButtonActionPerformed(evt);
  60.                                        }
  61.                                    }
  62.                                   );
  63.  
  64.         buttonPanel.add(okButton);
  65.  
  66.         cancelButton = new javax.swing.JButton();
  67.         cancelButton.setText("Cancel");
  68.         cancelButton.addActionListener(new java.awt.event.ActionListener() {
  69.                                            public void actionPerformed(java.awt.event.ActionEvent evt) {
  70.                                                cancelButtonActionPerformed(evt);
  71.                                            }
  72.                                        }
  73.                                       );
  74.  
  75.         buttonPanel.add(cancelButton);
  76.  
  77.  
  78.         getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
  79.  
  80.          pack();
  81.     }//GEN-END:initComponents
  82.  
  83.     private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
  84.         doClose(RET_OK);
  85.     }//GEN-LAST:event_okButtonActionPerformed
  86.  
  87.     private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
  88.         doClose(RET_CANCEL);
  89.     }//GEN-LAST:event_cancelButtonActionPerformed
  90.  
  91.     /** Closes the dialog */
  92.     private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
  93.         doClose(RET_CANCEL);
  94.     }//GEN-LAST:event_closeDialog
  95.  
  96.     private void doClose(int retStatus) {
  97.         returnStatus = retStatus;
  98.         setVisible(false);
  99.         dispose();
  100.     }
  101.  
  102.     /**
  103.     * param args the command line arguments
  104.     */
  105.     public static void main(String args[]) {
  106.         new OKDialog(new javax.swing.JFrame(), true).show();
  107.     }
  108.  
  109.     // Variables declaration - do not modify//GEN-BEGIN:variables
  110.     private javax.swing.JPanel buttonPanel;
  111.     private javax.swing.JButton okButton;
  112.     private javax.swing.JButton cancelButton;
  113.     // End of variables declaration//GEN-END:variables
  114.  
  115.     private int returnStatus = RET_CANCEL;
  116. }]]>
  117.                 </File>
  118.     </TemplateFiles>
  119.     
  120.     <FileOptions/>
  121.     
  122. </Template>
  123.