home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 February / VPR9802A.ISO / APP_DEMO / VC / SAMPLES.BIN / SoundPlayerClass.java < prev    next >
Text File  |  1997-10-27  |  6KB  |  192 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.util.Timer;
  9. import symantec.itools.awt.*;
  10. public class SoundPlayerClass extends Frame
  11. {
  12.     public SoundPlayerClass()
  13.     {
  14.         // This code is automatically generated by Visual Cafe when you add
  15.         // components to the visual environment. It instantiates and initializes
  16.         // the components. To modify the code, only use code syntax that matches
  17.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  18.         // parse your Java file into its visual environment.
  19.         //{{INIT_CONTROLS
  20.         setLayout(null);
  21.         setVisible(false);
  22.         setSize(insets().left + insets().right + 430,insets().top + insets().bottom + 270);
  23.         setBackground(new Color(12632256));
  24.         soundPlayer1 = new symantec.itools.multimedia.SoundPlayer();
  25.         try {
  26.             java.net.URL[] tempURL = new java.net.URL[5];
  27.             tempURL[0] = symantec.itools.net.RelativeURL.getURL("sounds/T1.AU");
  28.             tempURL[1] = symantec.itools.net.RelativeURL.getURL("sounds/T2.AU");
  29.             tempURL[2] = symantec.itools.net.RelativeURL.getURL("sounds/T3.AU");
  30.             tempURL[3] = symantec.itools.net.RelativeURL.getURL("sounds/T4.AU");
  31.             tempURL[4] = symantec.itools.net.RelativeURL.getURL("sounds/T5.AU");
  32.             soundPlayer1.setURLList(tempURL);
  33.         }
  34.         catch (java.net.MalformedURLException error) { }
  35.         catch(java.beans.PropertyVetoException e) { }
  36.         //$$ soundPlayer1.move(212,61);
  37.         imageViewer1 = new symantec.itools.multimedia.ImageViewer();
  38.         try {
  39.             imageViewer1.setURL(new java.net.URL("file:///C:/WINDOWS/DESKTOP/FINALLY/images/right.gif"));
  40.         }
  41.         catch (java.net.MalformedURLException error) { }
  42.         catch(java.beans.PropertyVetoException e) { }
  43.         imageViewer1.setBounds(insets().left + 42,insets().top + 7,136,131);
  44.         add(imageViewer1);
  45.         imageViewer2 = new symantec.itools.multimedia.ImageViewer();
  46.         try {
  47.             imageViewer2.setURL(new java.net.URL("file:///C:/WINDOWS/DESKTOP/FINALLY/images/right.gif"));
  48.         }
  49.         catch (java.net.MalformedURLException error) { }
  50.         catch(java.beans.PropertyVetoException e) { }
  51.         imageViewer2.setBounds(insets().left + 251,insets().top + 7,136,131);
  52.         add(imageViewer2);
  53.         imageButton1 = new symantec.itools.awt.ImageButton();
  54.         try {
  55.             imageButton1.setImageURL(new java.net.URL("file:///C:/WINDOWS/DESKTOP/FINALLY/images/stop.gif"));
  56.         }
  57.         catch (java.net.MalformedURLException error) { }
  58.         catch(java.beans.PropertyVetoException e) { }
  59.         imageButton1.setBounds(insets().left + 136,insets().top + 145,57,58);
  60.         add(imageButton1);
  61.         imageButton2 = new symantec.itools.awt.ImageButton();
  62.         try {
  63.             imageButton2.setImageURL(new java.net.URL("file:///C:/WINDOWS/DESKTOP/FINALLY/images/play.gif"));
  64.         }
  65.         catch (java.net.MalformedURLException error) { }
  66.         catch(java.beans.PropertyVetoException e) { }
  67.         imageButton2.setBounds(insets().left + 240,insets().top + 145,57,58);
  68.         add(imageButton2);
  69.         setTitle("Untitled");
  70.         //}}
  71.  
  72.         //{{INIT_MENUS
  73.         //}}
  74.  
  75.         //{{REGISTER_LISTENERS
  76.         SymWindow aSymWindow = new SymWindow();
  77.         this.addWindowListener(aSymWindow);
  78.         SymComponent aSymComponent = new SymComponent();
  79.         SymAction lSymAction = new SymAction();
  80.         imageButton1.addActionListener(lSymAction);
  81.         imageButton2.addActionListener(lSymAction);
  82.         //}}
  83.     }
  84.  
  85.     public SoundPlayerClass(String title)
  86.     {
  87.         this();
  88.         setTitle(title);
  89.     }
  90.  
  91.     public synchronized void show()
  92.     {
  93.         move(50, 50);
  94.         super.show();
  95.     }
  96.  
  97.     public void addNotify()
  98.     {
  99.         // Record the size of the window prior to calling parents addNotify.
  100.         Dimension d = getSize();
  101.         
  102.         super.addNotify();
  103.  
  104.         if (fComponentsAdjusted)
  105.             return;
  106.  
  107.         // Adjust components according to the insets
  108.         setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
  109.         Component components[] = getComponents();
  110.         for (int i = 0; i < components.length; i++)
  111.         {
  112.             Point p = components[i].getLocation();
  113.             p.translate(insets().left, insets().top);
  114.             components[i].setLocation(p);
  115.         }
  116.         fComponentsAdjusted = true;
  117.     }
  118.  
  119.     // Used for addNotify check.
  120.     boolean fComponentsAdjusted = false;
  121.  
  122.     //{{DECLARE_CONTROLS
  123.     symantec.itools.multimedia.SoundPlayer soundPlayer1;
  124.     symantec.itools.multimedia.ImageViewer imageViewer1;
  125.     symantec.itools.multimedia.ImageViewer imageViewer2;
  126.     symantec.itools.awt.ImageButton imageButton1;
  127.     symantec.itools.awt.ImageButton imageButton2;
  128.     //}}
  129.  
  130.     //{{DECLARE_MENUS
  131.     //}}
  132.  
  133.     class SymWindow extends java.awt.event.WindowAdapter
  134.     {
  135.         public void windowClosing(java.awt.event.WindowEvent event)
  136.         {
  137.             Object object = event.getSource();
  138.             if (object == SoundPlayerClass.this)
  139.                 Frame1_WindowClosing(event);
  140.         }
  141.     }
  142.     
  143.     void Frame1_WindowClosing(java.awt.event.WindowEvent event)
  144.     {
  145.         hide();         // hide the Frame
  146.     }
  147.  
  148.     class SymComponent extends java.awt.event.ComponentAdapter
  149.     {
  150.         public void componentHidden(java.awt.event.ComponentEvent event)
  151.         {
  152.             Object object = event.getSource();
  153.         }
  154.     }
  155.  
  156.     class SymAction implements java.awt.event.ActionListener
  157.     {
  158.         public void actionPerformed(java.awt.event.ActionEvent event)
  159.         {
  160.             Object object = event.getSource();
  161.             if (object == imageButton1)
  162.                 imageButton1_actionPerformed(event);
  163.             else if (object == imageButton2)
  164.                 imageButton2_actionPerformed(event);
  165.         }
  166.     }
  167.  
  168.     void imageButton1_actionPerformed(java.awt.event.ActionEvent event)
  169.     {
  170.         // to do: code goes here.
  171.              
  172.         //{{CONNECTION
  173.         // Stop the sound player
  174.         {
  175.             soundPlayer1.stop();
  176.         }
  177.         //}}
  178.     }
  179.  
  180.     void imageButton2_actionPerformed(java.awt.event.ActionEvent event)
  181.     {
  182.         // to do: code goes here.
  183.              
  184.         //{{CONNECTION
  185.         // Start the sound player
  186.         {
  187.             soundPlayer1.play();
  188.         }
  189.         //}}
  190.     }
  191. }
  192.