home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / VCSAMPL.BIN / NervousTextClass.java < prev    next >
Text File  |  1997-09-04  |  5KB  |  202 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 NervousTextClass extends Frame
  9. {
  10.     public NervousTextClass()
  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 + 430,insets().top + insets().bottom + 270);
  21.         setBackground(new Color(65535));
  22.         nervousText1 = new symantec.itools.multimedia.NervousText();
  23.         try {
  24.             nervousText1.setText("    Nervous Text");
  25.         }
  26.         catch(java.beans.PropertyVetoException e) { }
  27.         nervousText1.setBounds(insets().left + 19,insets().top + 28,401,57);
  28.         add(nervousText1);
  29.         button1 = new java.awt.Button();
  30.         button1.setActionCommand("button");
  31.         button1.setLabel("Change");
  32.         button1.setBounds(insets().left + 225,insets().top + 200,60,40);
  33.         add(button1);
  34.         button2 = new java.awt.Button();
  35.         button2.setActionCommand("button");
  36.         button2.setLabel("Close");
  37.         button2.setBounds(insets().left + 306,insets().top + 200,60,40);
  38.         add(button2);
  39.         button3 = new java.awt.Button();
  40.         button3.setActionCommand("button");
  41.         button3.setLabel("Pause");
  42.         button3.setBounds(insets().left + 144,insets().top + 200,60,40);
  43.         add(button3);
  44.         button4 = new java.awt.Button();
  45.         button4.setActionCommand("button");
  46.         button4.setLabel("Start");
  47.         button4.setBounds(insets().left + 63,insets().top + 200,60,40);
  48.         add(button4);
  49.         setTitle("Untitled");
  50.         //}}
  51.  
  52.         //{{INIT_MENUS
  53.         //}}
  54.  
  55.         //{{REGISTER_LISTENERS
  56.         SymWindow aSymWindow = new SymWindow();
  57.         this.addWindowListener(aSymWindow);
  58.         SymAction lSymAction = new SymAction();
  59.         button1.addActionListener(lSymAction);
  60.         button2.addActionListener(lSymAction);
  61.         button3.addActionListener(lSymAction);
  62.         button4.addActionListener(lSymAction);
  63.         //}}
  64.     }
  65.  
  66.     public NervousTextClass(String title)
  67.     {
  68.         this();
  69.         setTitle(title);
  70.     }
  71.  
  72.     public synchronized void show()
  73.     {
  74.         move(50, 50);
  75.         super.show();
  76.     }
  77.  
  78.     public void addNotify()
  79.     {
  80.         // Record the size of the window prior to calling parents addNotify.
  81.         Dimension d = getSize();
  82.         
  83.         super.addNotify();
  84.  
  85.         if (fComponentsAdjusted)
  86.             return;
  87.  
  88.         // Adjust components according to the insets
  89.         setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
  90.         Component components[] = getComponents();
  91.         for (int i = 0; i < components.length; i++)
  92.         {
  93.             Point p = components[i].getLocation();
  94.             p.translate(insets().left, insets().top);
  95.             components[i].setLocation(p);
  96.         }
  97.         fComponentsAdjusted = true;
  98.     }
  99.  
  100.     // Used for addNotify check.
  101.     boolean fComponentsAdjusted = false;
  102.  
  103.     //{{DECLARE_CONTROLS
  104.     symantec.itools.multimedia.NervousText nervousText1;
  105.     java.awt.Button button1;
  106.     java.awt.Button button2;
  107.     java.awt.Button button3;
  108.     java.awt.Button button4;
  109.     //}}
  110.  
  111.     //{{DECLARE_MENUS
  112.     //}}
  113.  
  114.     class SymWindow extends java.awt.event.WindowAdapter
  115.     {
  116.         public void windowClosing(java.awt.event.WindowEvent event)
  117.         {
  118.             Object object = event.getSource();
  119.             if (object == NervousTextClass.this)
  120.                 Frame1_WindowClosing(event);
  121.         }
  122.     }
  123.     
  124.     void Frame1_WindowClosing(java.awt.event.WindowEvent event)
  125.     {
  126.         hide();         // hide the Frame
  127.         dispose();
  128.     }
  129.  
  130.     class SymAction implements java.awt.event.ActionListener
  131.     {
  132.         public void actionPerformed(java.awt.event.ActionEvent event)
  133.         {
  134.             Object object = event.getSource();
  135.             if (object == button1)
  136.                 button1_Action(event);
  137.             else if (object == button2)
  138.                 button2_Action(event);
  139.             else if (object == button3)
  140.                 button3_Action(event);
  141.             else if (object == button4)
  142.                 button4_Action(event);
  143.         }
  144.     }
  145.  
  146.     void button1_Action(java.awt.event.ActionEvent event)
  147.     {
  148.         // to do: code goes here.
  149.              
  150.         //{{CONNECTION
  151.         // Set the text for NervousText...
  152.         {
  153.             try {
  154.                 nervousText1.setText("You just Changed the text");
  155.             }
  156.             catch(java.beans.PropertyVetoException e) { }
  157.         }
  158.         //}}
  159.     }
  160.  
  161.     void button2_Action(java.awt.event.ActionEvent event)
  162.     {
  163.         // to do: code goes here.
  164.              
  165.         //{{CONNECTION
  166.         // Hide the Frame
  167.         setVisible(false);
  168.         dispose();
  169.         //}}
  170.     }
  171.  
  172.     void button3_Action(java.awt.event.ActionEvent event)
  173.     {
  174.         // to do: code goes here.
  175.              
  176.         //{{CONNECTION
  177.         // Pause the NervousText
  178.         {
  179.             try {
  180.                 nervousText1.setPaused(true);
  181.             }
  182.             catch(java.beans.PropertyVetoException e) { }
  183.         }
  184.         //}}
  185.     }
  186.  
  187.     void button4_Action(java.awt.event.ActionEvent event)
  188.     {
  189.         // to do: code goes here.
  190.              
  191.         //{{CONNECTION
  192.         // Resume the NervousText
  193.         {
  194.             try {
  195.                 nervousText1.setPaused(false);
  196.             }
  197.             catch(java.beans.PropertyVetoException e) { }
  198.         }
  199.         //}}
  200.     }
  201. }
  202.