home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1997 April / Win95_04974.iso / docs / 00014 / 01403.exe / SAMPLES.ZIP / Sound\SoundApp.Java < prev   
Encoding:
Text File  |  1997-02-14  |  5.2 KB  |  212 lines

  1. /**********************************************************************
  2.  *  FileName: C:\JenAva\Samples\Sound\SoundApp.Java                   *
  3.  *                                                                    *
  4.  *  Source code generated with JenAva (R) v1.0                        *
  5.  **********************************************************************/
  6. //{{CODECINCH(COMMENT)
  7. //}}
  8.  
  9. import java.awt.*;
  10. import java.applet.Applet;
  11. import java.awt.image.*;
  12. import java.applet.AudioClip;
  13. import java.net.*;
  14. import java.io.*;
  15. import java.util.*;
  16.  
  17. //{{CODECINCH(IMPORT)
  18. //}}
  19.  
  20. //{{CODECINCH(BEFORE_ALL)
  21. //}}
  22.  
  23. public class SoundApp extends Applet implements ImageObserver
  24. {
  25.     //{{CODECINCH(BEGIN_APPLET)
  26.     //}}
  27.  
  28.     // ** GUI Objects Declarations
  29.     //{{CODECINCH(BEGIN_FORM_OBJDEC)
  30.     //}}
  31.  
  32.     public static JAFormBack CFBack;
  33.     public static JAButton Button4;
  34.     public static JAButton Button3;
  35.     public static JAButton Button2;
  36.     public static JAButton Button1;
  37.     public static JAStatic Text1;
  38.     public static JAGraphic Graphic1;
  39.  
  40.     //{{CODECINCH(END_FORM_OBJDEC)
  41.     //}}
  42.  
  43.     public static Image Graphic1Image;
  44.  
  45.     public static AudioClip SoundAudio;
  46.  
  47.     public static URL SoundUrl;
  48.  
  49.     public static SoundApp MainForm;
  50.  
  51.  
  52.     public void init()
  53.     {
  54.         //{{CODECINCH(BEGIN_INIT)
  55.         //}}
  56.  
  57.         MainForm = this;
  58.  
  59.         SoundUrl = getDocumentBase();
  60.  
  61.         Graphic1Image = getImage( SoundUrl, "images/Java.gif");
  62.  
  63.         setLayout( new GridLayout(1,1) );
  64.  
  65.         CFBack = new JAFormBack();
  66.         CFBack.setLayout( null );
  67.         CFBack.setBackground( new Color( 192, 192, 192 ) );
  68.         CFBack.setFont( new Font("Helvetica", Font.PLAIN, 12) );
  69.         add( CFBack );
  70.  
  71.         // ** Definitions of all objects for this form
  72.         //{{CODECINCH(BEGIN_FORM_OBJDEF)
  73.         //}}
  74.  
  75.         Button4 = new JAButton(255, 191, 127, 36, "Exit", 1, null, true, false, true, new Color(0, 128, 128) );
  76.         CFBack.add(Button4);
  77.         Button3 = new JAButton(254, 117, 127, 36, "LoopSound", 1, null, true, false, true, new Color(192, 192, 192) );
  78.         CFBack.add(Button3);
  79.         Button2 = new JAButton(253, 72, 127, 36, "StopSound", 1, null, true, false, true, new Color(192, 192, 192) );
  80.         CFBack.add(Button2);
  81.         Button1 = new JAButton(253, 27, 127, 36, "StartSound", 1, null, true, false, true, new Color(192, 192, 192) );
  82.         CFBack.add(Button1);
  83.         Text1 = new JAStatic(53, 12, 179, 49, "TimesRoman", 27, false, false, true, "A Sound Demo", new Color(0, 128, 0), new Color(192, 192, 192), false, new Color(0, 128, 0), true, 1, 4);
  84.         Graphic1 = new JAGraphic(50, 67, 181, 160, 1, SoundApp.Graphic1Image, true, false, true, true);
  85.         CFBack.add(Graphic1);
  86.  
  87.         //{{CODECINCH(END_FORM_OBJDEF)
  88.         //}}
  89.  
  90.  
  91.         resize( 441, 280 );
  92.  
  93.         postEvent( new Event( (Object)this, JAEvent.INITIALIZE, (Object)this ) );
  94.  
  95.         //{{CODECINCH(END_INIT)
  96.         //}}
  97.     }
  98.  
  99.     public void paint( Graphics g )
  100.     {
  101.         //{{CODECINCH(BEGIN_FORM_PAINT)
  102.         //}}
  103.     
  104.         // ** Painting of all objects for this form
  105.     
  106.         if(Button4.bVisible == true)
  107.             Button4.reshape(Button4.xPos, Button4.yPos, Button4.Width, Button4.Height);
  108.         if(Button3.bVisible == true)
  109.             Button3.reshape(Button3.xPos, Button3.yPos, Button3.Width, Button3.Height);
  110.         if(Button2.bVisible == true)
  111.             Button2.reshape(Button2.xPos, Button2.yPos, Button2.Width, Button2.Height);
  112.         if(Button1.bVisible == true)
  113.             Button1.reshape(Button1.xPos, Button1.yPos, Button1.Width, Button1.Height);
  114.         if(Text1.bVisible == true)
  115.             Text1.paint( CFBack.getGraphics() );
  116.         if(Graphic1.bVisible == true)
  117.             Graphic1.reshape(Graphic1.xPos, Graphic1.yPos, Graphic1.Width, Graphic1.Height);
  118.  
  119.         //{{CODECINCH(END_FORM_PAINT)
  120.         //}}
  121.     }
  122.  
  123.     public boolean handleEvent( Event evt )
  124.     {
  125.         //{{CODECINCH(BEGIN_FORM_HANDLEEVENT)
  126.         //}}
  127.  
  128.         if( ( evt.target ).equals( Button4 ) )
  129.         {
  130.             if( evt.id == JAEvent.CLICK )
  131.             {
  132.                 JAFunctions.EXIT();
  133.             }
  134.         }
  135.  
  136.         if( ( evt.target ).equals( Button3 ) )
  137.         {
  138.             if( evt.id == JAEvent.CLICK )
  139.             {
  140.                 SoundApp.SoundAudio = SoundApp.MainForm.getAudioClip( SoundApp.SoundUrl, "Audio/Music.au" );
  141.  
  142.                 JAFunctions.LOOPSOUND(SoundApp.SoundAudio);
  143.             }
  144.         }
  145.  
  146.         if( ( evt.target ).equals( Button2 ) )
  147.         {
  148.             if( evt.id == JAEvent.CLICK )
  149.             {
  150.                 if( SoundApp.SoundAudio != null )
  151.                     JAFunctions.STOPSOUND(SoundApp.SoundAudio);
  152.             }
  153.         }
  154.  
  155.         if( ( evt.target ).equals( Button1 ) )
  156.         {
  157.             if( evt.id == JAEvent.CLICK )
  158.             {
  159.                 SoundApp.SoundAudio = SoundApp.MainForm.getAudioClip( SoundApp.SoundUrl, "Audio/Music.au" );
  160.  
  161.                 JAFunctions.STARTSOUND(SoundApp.SoundAudio);
  162.             }
  163.         }
  164.  
  165.         if( ( evt.target ).equals( Graphic1 ) )
  166.         {
  167.         }
  168.  
  169.         if( evt.id == Event.MOUSE_UP )
  170.         {
  171.             Button4.bMouseDown = false;
  172.             Button3.bMouseDown = false;
  173.             Button2.bMouseDown = false;
  174.             Button1.bMouseDown = false;
  175.         }
  176.  
  177.         if( evt.target instanceof JATextField )
  178.         {
  179.             if( evt.id == JAEvent.SELCHANGE )
  180.                 evt.id = Event.KEY_PRESS;
  181.         }
  182.  
  183.         if( evt.id == Event.WINDOW_DESTROY )
  184.         {
  185.             postEvent( new Event( (Object)this, JAEvent.CLOSE, (Object)this ) );
  186.             JAFunctions.HIDE( this );
  187.             JAFunctions.EXIT();
  188.  
  189.             return true;
  190.         }
  191.  
  192.         //{{CODECINCH(END_FORM_HANDLEEVENT)
  193.         //}}
  194.  
  195.         return false;
  196.     }
  197.  
  198.     public static void MainFormForm_UpdateTableToLinks()
  199.     {
  200.     }
  201.  
  202.     public static void MainFormForm_UpdateTableFromLinks()
  203.     {
  204.     }
  205.  
  206.     //{{CODECINCH(END_APPLET)
  207.     //}}
  208. }
  209.  
  210. //{{CODECINCH(AFTER_ALL)
  211. //}}
  212.