import java.applet.*;
import java.net.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
// Note: the sound files are not provided so you won't get the sounds if
// you compile and run this
public class ShootSimple implements ActionListener
{
JButton b = new JButton("click");
public ShootSimple()
{
JFrame frame = new JFrame("Sound");
frame.add(b);
b.addActionListener(this);
frame.setSize(400,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
try
{
AudioClip open = Applet.newAudioClip(new URL("file:/h:/courses/shoot/sound/tos-deadjim.au"));
open.play();
} catch (MalformedURLException murle)
{};
}
public static void main (String[] args)
{
new ShootSimple();
System.out.println("Running");
}
}
|