|
-
August 15th, 2001, 10:10 AM
#7
Re: static vs non-static method calls
At last I done it. Hear how I done it
/**
* Java code for playing sound on an Applet.
* @author Ajay Parmar
* e-mail: [email protected]
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
/*
<applet code="MySound" width=200 height=200>
</applet>
*/
public class MySound extends Applet implements ActionListener {
Button bPlay;
AudioClip audioClip;
URL clipPath;
public void init() {
bPlay = new Button("Play Sound");
try {
clipPath = new URL(this.getCodeBase()+"MySound.wav");
}
catch(Exception e) { }
audioClip = this.newAudioClip(clipPath);
add(bPlay);
bPlay.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
if(ae.getSource() == bPlay) {
audioClip.play();
}
}
}
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
|
Click Here to Expand Forum to Full Width
|