-
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 05:53 AM.
-
okay I've left this long enough with no reply, please I need help
-
What have you coded in your HTML page to contain the applet?
-
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 07:41 PM.
-
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.
-
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 09:01 AM.
-
<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
-
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 04:39 AM.
Similar Threads
-
By meghalgandhi in forum .NET
Replies: 3
Last Post: 07-01-2005, 10:04 AM
-
By Charlie Flynn in forum Java
Replies: 3
Last Post: 08-23-2001, 11:01 AM
-
Replies: 1
Last Post: 08-16-2001, 08:52 AM
-
By Theodore in forum java.announcements
Replies: 1
Last Post: 01-26-2001, 06:59 AM
-
Replies: 0
Last Post: 08-21-2000, 07: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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks