home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / WDESAMPL.BIN / FireWorksClass.java < prev    next >
Text File  |  1998-02-26  |  4KB  |  169 lines

  1. /*
  2.     A basic extension of the java.awt.Frame class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. import symantec.itools.multimedia.*;
  8. import symantec.itools.multimedia.Firework;
  9. public class FireWorksClass extends Frame
  10. {
  11.     public FireWorksClass()
  12.     {
  13.         // This code is automatically generated by Visual Cafe when you add
  14.         // components to the visual environment. It instantiates and initializes
  15.         // the components. To modify the code, only use code syntax that matches
  16.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  17.         // parse your Java file into its visual environment.
  18.         //{{INIT_CONTROLS
  19.         setLayout(null);
  20.         setVisible(false);
  21.         setSize(433,271);
  22.         setBackground(new Color(0));
  23.         firework1 = new symantec.itools.multimedia.Firework();
  24.         firework1.setBounds(49,21,357,173);
  25.         add(firework1);
  26.         button1 = new java.awt.Button();
  27.         button1.setActionCommand("button");
  28.         button1.setLabel("Pause");
  29.         button1.setBounds(80,204,60,40);
  30.         add(button1);
  31.         button2 = new java.awt.Button();
  32.         button2.setActionCommand("button");
  33.         button2.setLabel("Close");
  34.         button2.setBounds(288,204,60,40);
  35.         add(button2);
  36.         button3 = new java.awt.Button();
  37.         button3.setActionCommand("button");
  38.         button3.setLabel("Start");
  39.         button3.setBounds(184,204,60,40);
  40.         add(button3);
  41.         setTitle("Untitled");
  42.         //}}
  43.  
  44.         //{{INIT_MENUS
  45.         //}}
  46.  
  47.         //{{REGISTER_LISTENERS
  48.         SymWindow aSymWindow = new SymWindow();
  49.         this.addWindowListener(aSymWindow);
  50.         SymAction lSymAction = new SymAction();
  51.         button1.addActionListener(lSymAction);
  52.         button3.addActionListener(lSymAction);
  53.         button2.addActionListener(lSymAction);
  54.         //}}
  55.     }
  56.  
  57.     public FireWorksClass(String title)
  58.     {
  59.         this();
  60.         setTitle(title);
  61.     }
  62.  
  63.     public synchronized void show()
  64.     {
  65.         move(50, 50);
  66.         super.show();
  67.     }
  68.  
  69.     public void addNotify()
  70.     {
  71.         // Record the size of the window prior to calling parents addNotify.
  72.         Dimension d = getSize();
  73.         
  74.         super.addNotify();
  75.  
  76.         if (fComponentsAdjusted)
  77.             return;
  78.  
  79.         // Adjust components according to the insets
  80.         setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
  81.         Component components[] = getComponents();
  82.         for (int i = 0; i < components.length; i++)
  83.         {
  84.             Point p = components[i].getLocation();
  85.             p.translate(insets().left, insets().top);
  86.             components[i].setLocation(p);
  87.         }
  88.         fComponentsAdjusted = true;
  89.     }
  90.  
  91.     // Used for addNotify check.
  92.     boolean fComponentsAdjusted = false;
  93.  
  94.     //{{DECLARE_CONTROLS
  95.     symantec.itools.multimedia.Firework firework1;
  96.     java.awt.Button button1;
  97.     java.awt.Button button2;
  98.     java.awt.Button button3;
  99.     //}}
  100.  
  101.     //{{DECLARE_MENUS
  102.     //}}
  103.  
  104.     class SymWindow extends java.awt.event.WindowAdapter
  105.     {
  106.         public void windowClosing(java.awt.event.WindowEvent event)
  107.         {
  108.             Object object = event.getSource();
  109.             if (object == FireWorksClass.this)
  110.                 Frame1_WindowClosing(event);
  111.         }
  112.     }
  113.     
  114.     void Frame1_WindowClosing(java.awt.event.WindowEvent event)
  115.     {
  116.         hide();         // hide the Frame
  117.         dispose();
  118.     }
  119.  
  120.     class SymAction implements java.awt.event.ActionListener
  121.     {
  122.         public void actionPerformed(java.awt.event.ActionEvent event)
  123.         {
  124.             Object object = event.getSource();
  125.             if (object == button1)
  126.                 button1_Action(event);
  127.             else if (object == button3)
  128.                 button3_Action(event);
  129.             else if (object == button2)
  130.                 button2_Action(event);
  131.         }
  132.     }
  133.  
  134.     void button1_Action(java.awt.event.ActionEvent event)
  135.     {
  136.         // to do: code goes here.
  137.              
  138.         //{{CONNECTION
  139.         // Freeze all rockets
  140.         {
  141.             firework1.freezeRockets();
  142.         }
  143.         //}}
  144.     }
  145.  
  146.     void button3_Action(java.awt.event.ActionEvent event)
  147.     {
  148.         // to do: code goes here.
  149.              
  150.         //{{CONNECTION
  151.         // Unfreeze all rockets
  152.         {
  153.             firework1.unfreezeRockets();
  154.         }
  155.         //}}
  156.     }
  157.  
  158.     void button2_Action(java.awt.event.ActionEvent event)
  159.     {
  160.         // to do: code goes here.
  161.              
  162.         //{{CONNECTION
  163.         // Hide the Frame
  164.         setVisible(false);
  165.         dispose();
  166.         //}}
  167.     }
  168. }
  169.