0

This program is intended to produce a beep sound using applet context. I got error cannot find the symbol METHOD SetAudioClip(URL,string). Please explain what is url and string in these case.

import java.applet.*;
import java.awt.event.*;
import java.awt.*;

public class Boops extends Applet implements MouseListener
{

AudioClip c;

public void init()
{
    c=SetActionClip(getCodeBase(),"beep.ac");
    addMouseListener(this);
}

public void mouseClicked(MouseEvent e)
{
    c.play();
}
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
RIYA tr
  • 7
  • 2
  • 1) Why code an applet? If it is due to the teacher specifying it, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). 2) Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT using components in favor of Swing. 3) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! – Andrew Thompson Feb 14 '15 at 01:01

2 Answers2

1

Just remove white space in Set ActionClip:

c=SetActionClip(getCodeBase(),"beep.ac");
Jarlax
  • 1,586
  • 10
  • 20
  • 1
    `SetActionClip` If that were a method inherited from `java.applet.Applet` or defined in this code (it's not either of those things), it should be `setActionClip` (note case). – Andrew Thompson Feb 14 '15 at 01:07
1
error ; missing at c=Set ActionClip(getCodeBase(),"beep.ac"); 

Use Applet.getAudioClip(URL,String) instead, which:

Returns the AudioClip object specified by the URL and name arguments.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433