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

  1. /*
  2.     A basic extension of the java.awt.Frame class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. import geo.emblaze.*;
  8. import geo.emblaze.Emblaze20;
  9. public class EmblazeClass extends Frame
  10. {
  11.     public EmblazeClass()
  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(600,458);
  22.         setBackground(new Color(0));
  23.         emblaze201 = new geo.emblaze.Emblaze20();
  24.         try {
  25.             emblaze201.setFileURL(symantec.itools.net.RelativeURL.getURL("blaze/symantec.blz"));
  26.         }
  27.         catch (java.net.MalformedURLException error) { }
  28.         emblaze201.setBounds(27,23,543,339);
  29.         add(emblaze201);
  30.         button1 = new java.awt.Button();
  31.         button1.setActionCommand("button");
  32.         button1.setLabel("Close");
  33.         button1.setBounds(136,385,60,40);
  34.         add(button1);
  35.         button2 = new java.awt.Button();
  36.         button2.setActionCommand("button");
  37.         button2.setLabel("Start");
  38.         button2.setBounds(270,385,60,40);
  39.         add(button2);
  40.         button3 = new java.awt.Button();
  41.         button3.setActionCommand("button");
  42.         button3.setLabel("Pause");
  43.         button3.setBounds(404,385,60,40);
  44.         add(button3);
  45.         setTitle("Untitled");
  46.         //}}
  47.  
  48.         //{{INIT_MENUS
  49.         //}}
  50.  
  51.         //{{REGISTER_LISTENERS
  52.         SymWindow aSymWindow = new SymWindow();
  53.         this.addWindowListener(aSymWindow);
  54.         SymAction lSymAction = new SymAction();
  55.         button1.addActionListener(lSymAction);
  56.         button2.addActionListener(lSymAction);
  57.         button3.addActionListener(lSymAction);
  58.         //}}
  59.     }
  60.  
  61.     public EmblazeClass(String title)
  62.     {
  63.         this();
  64.         setTitle(title);
  65.     }
  66.  
  67.     public synchronized void show()
  68.     {
  69.         move(50, 50);
  70.         super.show();
  71.     }
  72.  
  73.     public void addNotify()
  74.     {
  75.         // Record the size of the window prior to calling parents addNotify.
  76.         Dimension d = getSize();
  77.         
  78.         super.addNotify();
  79.  
  80.         if (fComponentsAdjusted)
  81.             return;
  82.  
  83.         // Adjust components according to the insets
  84.         setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
  85.         Component components[] = getComponents();
  86.         for (int i = 0; i < components.length; i++)
  87.         {
  88.             Point p = components[i].getLocation();
  89.             p.translate(insets().left, insets().top);
  90.             components[i].setLocation(p);
  91.         }
  92.         fComponentsAdjusted = true;
  93.     }
  94.  
  95.     // Used for addNotify check.
  96.     boolean fComponentsAdjusted = false;
  97.  
  98.     //{{DECLARE_CONTROLS
  99.     geo.emblaze.Emblaze20 emblaze201;
  100.     java.awt.Button button1;
  101.     java.awt.Button button2;
  102.     java.awt.Button button3;
  103.     //}}
  104.  
  105.     //{{DECLARE_MENUS
  106.     //}}
  107.  
  108.     class SymWindow extends java.awt.event.WindowAdapter
  109.     {
  110.         public void windowClosing(java.awt.event.WindowEvent event)
  111.         {
  112.             Object object = event.getSource();
  113.             if (object == EmblazeClass.this)
  114.                 Frame1_WindowClosing(event);
  115.         }
  116.     }
  117.     
  118.     void Frame1_WindowClosing(java.awt.event.WindowEvent event)
  119.     {
  120.         hide();         // hide the Frame
  121.         dispose();
  122.     }
  123.  
  124.     class SymAction implements java.awt.event.ActionListener
  125.     {
  126.         public void actionPerformed(java.awt.event.ActionEvent event)
  127.         {
  128.             Object object = event.getSource();
  129.             if (object == button1)
  130.                 button1_Action(event);
  131.             else if (object == button2)
  132.                 button2_Action(event);
  133.             else if (object == button3)
  134.                 button3_Action(event);
  135.         }
  136.     }
  137.  
  138.     void button1_Action(java.awt.event.ActionEvent event)
  139.     {
  140.         // to do: code goes here.
  141.              
  142.         //{{CONNECTION
  143.         // Hide the Frame
  144.         setVisible(false);
  145.         dispose();
  146.         //}}
  147.     }
  148.  
  149.     void button2_Action(java.awt.event.ActionEvent event)
  150.     {
  151.         // to do: code goes here.
  152.              
  153.         //{{CONNECTION
  154.         // Start the animation
  155.         {
  156.             emblaze201.start();
  157.         }
  158.         //}}
  159.     }
  160.  
  161.     void button3_Action(java.awt.event.ActionEvent event)
  162.     {
  163.         // to do: code goes here.
  164.              
  165.         //{{CONNECTION
  166.         // Pause the animation
  167.         {
  168.             emblaze201.freeze();
  169.         }
  170.         //}}
  171.     }
  172. }
  173.