Sound Applet refuses to show in any browser


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Sound Applet refuses to show in any browser

  1. #1
    Join Date
    Jan 2007
    Posts
    5

    Sound Applet refuses to show in any browser

    Okay I'm sorry if this has been posted elsewhere but I haven't been able to find it and have been stuck for a long time.

    The problem is I cannot get my applet to work right in any browser

    I'm using jpadpro to write and compile my code. Once its compiled. I used the inbuilt applet tester in the program which works absoluetly fine. I then try to stick it into a html file and load it in my installed browsers (mozilla and ie) and it refuses to load the applet.

    Here is my code:

    Code:
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    
    public class SoundApplet extends JApplet implements ActionListener
    {
    	URL sound; AudioClip music;
    
    	public void init()
    
    	{
    		try
    		{
    			sound = new URL("file:music.wav");
    			music = JApplet.newAudioClip(sound);
    			music.loop();
    		}
    		catch(MalformedURLException error){}
    		Container contentArea = getContentPane();
    		JButton button = new JButton("Click To Stop Sound");
    		button.addActionListener(this);
    		contentArea.add(button);
    	}
    	public void actionPerformed(ActionEvent event)
    	{music.stop();}
    }
    Anyhow I'd be very thankful for any help
    Last edited by the_6th_Monkey; 01-26-2007 at 06:53 AM.

  2. #2
    Join Date
    Jan 2007
    Posts
    5
    okay I've left this long enough with no reply, please I need help

  3. #3
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    What have you coded in your HTML page to contain the applet?

  4. #4
    Join Date
    Jan 2007
    Posts
    5
    Here is my html code, I hope this helps:

    HTML Code:
    <html>
    
    <head>
    <title>Sound Applet</title>
    </head>
    
    <body>
    <applet code = "SoundApplet.class"
    	width = "300" height = "60">
    
    You require a Java-enabled browser to view this applet.
    
    </applet>
    
    </body>
    
    </html>
    Thanks for helping btw
    Last edited by the_6th_Monkey; 02-02-2007 at 08:41 PM.

  5. #5
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    The example which you'll find by following the link does not put the name of the applet in quotation marks.

    http://java.sun.com/docs/books/tutor...applettag.html

    If you will look at the sections following that page you'll see other ways to include an applet in a HTML page. The "applet" tag is deprecated and the standards makers want us to be using "object" ... and the Mozilla people have embed. It's all there.

  6. #6
    Join Date
    Jan 2007
    Posts
    5
    Thanks for the help but it seems I'm still stuck


    Here is my new html:

    HTML Code:
    <html>
    
    <head>
    <title>Sound Applet</title>
    </head>
    
    <body>
    
    
    <OBJECT codetype="application/java"
            classid="java:SoundApplet.class"
    	width="500" height="500"
            codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"
    	pluginspage="http://java.sun.com/products/plugin/index.html">
    </OBJECT>
    
    
    
    </body>
    
    </html>
    I still see a big empty applet box with a red cross
    Last edited by the_6th_Monkey; 02-03-2007 at 10:01 AM.

  7. #7
    Join Date
    Apr 2006
    Posts
    14
    <OBJECT codetype="application/java"
    classid="java:SoundApplet.class"
    width="500" height="500"
    codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"
    pluginspage="http://java.sun.com/products/plugin/index.html">
    </OBJECT>
    maybe the .class file isn't there

  8. #8
    Join Date
    Jan 2007
    Posts
    5
    It is, I know I'm new to this but I've had other simpler applets working in the past

    Well maybe I should look for other examples of doing the same thing if this method blatantly fails

    p.s. never buy the book java in easy steps
    Last edited by the_6th_Monkey; 02-05-2007 at 05:39 AM.

Similar Threads

  1. How to Show WinForm in Browser Like I.E. ??
    By meghalgandhi in forum .NET
    Replies: 3
    Last Post: 07-01-2005, 11:04 AM
  2. Replies: 3
    Last Post: 08-23-2001, 12:01 PM
  3. Replies: 1
    Last Post: 08-16-2001, 09:52 AM
  4. View an applet in browser
    By Theodore in forum java.announcements
    Replies: 1
    Last Post: 01-26-2001, 07:59 AM
  5. Replies: 0
    Last Post: 08-21-2000, 08:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center