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