home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / SaveChangesWindow.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  5.4 KB  |  197 lines

  1. /*
  2.     A basic extension of the java.awt.Frame class
  3.  */
  4. package symantec.itools.db.beans.binding;
  5.  
  6. import java.awt.*;
  7.  
  8. import symantec.itools.awt.shape.Rect;
  9. import symantec.itools.awt.WrappingLabel;
  10. public class SaveChangesWindow extends symantec.itools.awt.util.dialog.ModalDialog implements SaveChangesDialog
  11. {
  12.     public SaveChangesWindow()
  13.     {
  14.  
  15.         this(true);
  16.        
  17.     
  18.         //{{REGISTER_LISTENERS
  19.         SymAction lSymAction = new SymAction();
  20.         button2.addActionListener(lSymAction);
  21.         //}}
  22.     }
  23.     public SaveChangesWindow(boolean cancel)
  24.     {
  25.         // This code is automatically generated by Visual Cafe when you add
  26.         // components to the visual environment. It instantiates and initializes
  27.         // the components. To modify the code, only use code syntax that matches
  28.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  29.         // parse your Java file into its visual environment.
  30.         //{{INIT_CONTROLS
  31.         
  32.         super(new Frame(), "");
  33.         setLayout(null);
  34.         setVisible(false);
  35.         setSize(insets().left + insets().right + 320,insets().top + insets().bottom + 160);
  36.         super.getParent().setBounds(20,20,insets().left + insets().right + 320,insets().top + insets().bottom + 160);
  37.         setBackground(new Color(12632256));
  38.         panel1 = new java.awt.Panel();
  39.         panel1.setLayout(null);
  40.         panel1.setBounds(0,0,320,110);
  41.         panel1.setBackground(new Color(12632256));
  42.         add(panel1);
  43.         rect1 = new symantec.itools.awt.shape.Rect();
  44.         try {
  45.             rect1.setBevelStyle(symantec.itools.awt.shape.Rect.BEVEL_LOWERED);
  46.         }
  47.         catch(java.beans.PropertyVetoException e) { }
  48.         rect1.setBounds(5,12,310,90);
  49.         panel1.add(rect1);
  50.         label1 = new java.awt.Label("Warning",Label.CENTER);
  51.         label1.setBounds(14,4,54,18);
  52.         label1.setFont(new Font("Dialog", Font.BOLD, 12));
  53.         panel1.add(label1);
  54.         label2 = new java.awt.Label("You have made some changes in your details.",Label.CENTER);
  55.         label2.setBounds(17,30,285,23);
  56.         panel1.add(label2);
  57.         label3 = new java.awt.Label("Do you wish to save them before proceeding ?",Label.CENTER);
  58.         label3.setBounds(17,58,285,23);
  59.         panel1.add(label3);
  60.         panel2 = new java.awt.Panel();
  61.         if(cancel)panel2.setLayout(new GridLayout(1,3,20,0));
  62.         else panel2.setLayout(new GridLayout(1,2,40,0));
  63.         panel2.setBounds(10,110,300,40);
  64.         panel2.setBackground(new Color(12632256));
  65.         add(panel2);
  66.         button1 = new java.awt.Button();
  67.         button1.setLabel("Save");
  68.         button1.setBounds(0,0,300,40);
  69.         button1.setFont(new Font("Dialog", Font.BOLD, 12));
  70.         button1.setBackground(new Color(12632256));
  71.         panel2.add(button1);
  72.         button2 = new java.awt.Button();
  73.         button2.setLabel("Discard");
  74.         button2.setBounds(106,0,140,40);
  75.         button2.setFont(new Font("Dialog", Font.BOLD, 12));
  76.         button2.setBackground(new Color(12632256));
  77.         panel2.add(button2);
  78.         button3 = new java.awt.Button();
  79.         button3.setLabel("Cancel");
  80.         button3.setBounds(212,0,86,40);
  81.         button3.setFont(new Font("Dialog", Font.BOLD, 12));
  82.         button3.setBackground(new Color(12632256));
  83.         if(cancel)panel2.add(button3);
  84.         setTitle("Untitled");
  85.         //}}
  86.  
  87.         //{{INIT_MENUS
  88.         //}}
  89.  
  90.         //{{REGISTER_LISTENERS
  91.         SymAction lSymAction = new SymAction();
  92.         button1.addActionListener(lSymAction);
  93.         button2.addActionListener(lSymAction);
  94.         button3.addActionListener(lSymAction);
  95.         //}}
  96.     }
  97.  
  98.     public SaveChangesWindow(String title)
  99.     {
  100.         this();
  101.         setTitle(title);
  102.     }
  103.  
  104.     /**
  105.      * Shows or hides the component depending on the boolean flag b.
  106.      * @param b  if true, show the component; otherwise, hide the component.
  107.      * @see java.awt.Component#isVisible
  108.      */
  109.     public void setVisible(boolean b)
  110.     {
  111.         if(b)
  112.         {
  113.             setLocation(50, 50);
  114.         }
  115.         super.setVisible(b);
  116.     }
  117.  
  118.     public void addNotify()
  119.     {
  120.         // Record the size of the window prior to calling parents addNotify.
  121.         Dimension d = getSize();
  122.  
  123.         super.addNotify();
  124.  
  125.         if (fComponentsAdjusted)
  126.             return;
  127.  
  128.         // Adjust components according to the insets
  129.         setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
  130.         Component components[] = getComponents();
  131.         for (int i = 0; i < components.length; i++)
  132.         {
  133.             Point p = components[i].getLocation();
  134.             p.translate(insets().left, insets().top);
  135.             components[i].setLocation(p);
  136.         }
  137.         fComponentsAdjusted = true;
  138.     }
  139.  
  140.     // Used for addNotify check.
  141.     boolean fComponentsAdjusted = false;
  142.  
  143.     //{{DECLARE_CONTROLS
  144.     java.awt.Panel panel1;
  145.     symantec.itools.awt.shape.Rect rect1;
  146.     java.awt.Label label1;
  147.     java.awt.Label label2;
  148.     java.awt.Label label3;
  149.     java.awt.Panel panel2;
  150.     java.awt.Button button1;
  151.     java.awt.Button button2;
  152.     java.awt.Button button3;
  153.     //}}
  154.  
  155.     //{{DECLARE_MENUS
  156.     //}}
  157.     int returnval=0;
  158.     public int run(){
  159.         super.show();
  160.         return returnval;
  161.         }
  162.         
  163.     
  164.     class SymAction implements java.awt.event.ActionListener
  165.     {
  166.         public void actionPerformed(java.awt.event.ActionEvent event)
  167.         {
  168.             Object object = event.getSource();
  169.             if (object == button1)
  170.                 button1_ActionPerformed(event);
  171.             else if (object == button3)
  172.                 button3_ActionPerformed(event);
  173.             else if (object == button2)
  174.                 button2_ActionPerformed(event);
  175.         }
  176.     }
  177.  
  178.     void button1_ActionPerformed(java.awt.event.ActionEvent event)
  179.     {
  180.         returnval=YES;
  181.         closeDialog();
  182.         }
  183.     void button2_ActionPerformed(java.awt.event.ActionEvent event)
  184.     {
  185.         returnval=NO;
  186.         closeDialog();
  187.         //}}
  188.     }
  189.     void button3_ActionPerformed(java.awt.event.ActionEvent event)
  190.     {
  191.         returnval=CANCEL;
  192.         closeDialog();
  193.         }
  194.  
  195.     
  196. }
  197.