©1994-2003 Kevin Boone
Home     Section index     K-Zone home Simple Java programs

Site search

Glossary
Confused by computer jargon? Look it up!

Shameless plug


Now available!

Articles
- Ten-minute guide to setting up a WAP site

- Talk like your boss: new developments in managerese

More...

Development
File handling in the Linux kernel

Java development for the Sony-Ericsson P800

SunONE Application Server 7 FAQ

More...

Linux
Using Linux with the Treo 600

- Linux on the Tecra M1

- Some notes on openzaurus

More...

Download
Java stuff

Linux stuff

More...

(Please read the download policy)

Home automation
The X10 system

Linux TW723 driver

More...

The K-Zone
K-Zone computing

K-Zone law

K-Zone education and science

K-Zone motorcycles

K-Zone DIY

K-Zone railways

K-Zone martial arts

About the author

K-Zone home page

 
Software development
Computing
Hello1.java
Add1.java
Add1_1.java
AwtTest.java
Button1.java
Button2.java
Calculator.java
CalculatorApp.java
ClockApplet.java
CountSpace1.java
DateTime.java
Div1.java
DoNothing.java
Factorial1.java
Factorial2.java
FontChooser.java
IfTest.java
Inheritance1.java
Loan.java
DiceThrower.java
MultiplicationTable.java
Queue.java
Reverse1.java
Stressometer.java
TextReaderTest.java
WebMerge.java
Zener.java
`SoundApplet' example program: plays sound samples; demonstrates sound handling

SoundApplet.java

/*==================================================================
Kevin Boone, August 98
==================================================================*/
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.net.URL;

class ButtonHandler implements ActionListener
{
URL codeBase;
String clipName;
Applet ownerApplet;
public ButtonHandler (Applet _ownerApplet, 
		URL _codeBase, String _clipName)
	{
	codeBase = _codeBase;
	clipName = _clipName;
	ownerApplet = _ownerApplet;
	}

public void actionPerformed (ActionEvent e)
	{
	ownerApplet.play (codeBase, clipName);
	System.out.println (clipName);
	}
}

public class SoundApplet extends Applet 
{
public void start ()
	{
	Button button1 = new Button("Clip1");
	button1.addActionListener (new ButtonHandler
		(this, getCodeBase(), "fatherted1.au"));
	add (button1);
	Button button2 = new Button("Clip2");
	button2.addActionListener (new ButtonHandler 
		(this, getCodeBase(), "fatherted2.au"));
	add (button2);
	Button button3 = new Button("Clip3");
	button3.addActionListener (new ButtonHandler 
		(this, getCodeBase(), "fatherted3.au"));
	add (button3);
	}
}