I'm here and back again to bother some of you about my problem.
I shall go straight to the point now since I don't have much time to dilly-dally.
So here's my code:
//Did I place all of them in the right package?
import javax.swing.JApplet;
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Font;
import java.net.URL;
public class abscbn extends JApplet
{
Font a = new Font("Monotype Corsiva", Font.BOLD, 72);
AudioClip song;
URL path;
//I am not so sure about this whole audio thing.
//I tried to follow the instructions step by step in the other topics with the same problem as
//mine but it seems I made my program worse.
abscbn(String FoR) //FoR is the filename of my .mid file
{
try
{
path = new URL(getCodeBase(), "FoR.mid");
//tried to remove the quotation marks but, I get an error.
song = Applet.newAudioClip(path);
}
catch(Exception e) {}
}
public void playSound()
{
song.loop();
}
//I was also wondering if I should place all class here? The stopSound() and the
//playSoundOnce()?
public void init()
{
abscbn bg = new abscbn("FoR.mid");
bg.playSound();
}
//should I place the init() class somewhere else?
public void paint(Graphics g)
{
//super.paint(g);
g.setColor(Color.BLACK);
g.fillRect(0,0,700,700);
g.setFont(a);
g.setColor(Color.WHITE);
g.drawString("A B S", 225, 70);
g.drawString("C B N", 210, 553);
g.setColor(Color.WHITE);
g.fillRect(154,92,420,406);
g.setColor(Color.BLACK);
g.fillRect(155,93,418,404);
g.setColor(Color.RED);
g.fillOval(170,105,386,377);
g.setColor(Color.BLACK);
g.fillOval(192,120,342,346);
g.setColor(Color.GREEN);
g.fillOval(226,162,274,266);
g.setColor(Color.BLACK);
g.fillOval(242,181,242,228);
g.setColor(Color.BLUE);
g.fillOval(266,212,193,169);
g.setColor(Color.BLACK);
g.fillOval(291,231,143,129);
g.setColor(Color.WHITE);
g.fillRect(343,261,37,237);
}
}
And here is the html file:
<html> <applet code="abscbn.class" width="700" height="700"> </applet> </html>
So like I said, I hopped from one topic to another with the same problem as mine.
The real problem in my codes is that, before I added the codes for the audio, my program was sure running fine. It displays everything I have drawn.
BUT. After I added the codes for the audio file, whenever I run the html file, the applet viewer appears but the status bar states that my applet was not initialized.
I do make sure to compile the .java file first before running the .html file but still, no avail.
I tried opening the .html file in my browser(Firefox) but I get an error (which I could not understand).
Also, I made sure that all my files are saved under the same folder.
So yes, I'm here to ask the question that has been asked so many times. Sorry.
Hope someone could help me?

New Topic/Question
Reply




MultiQuote







|