FileDocCategorySizeDatePackage
NoisyButton.javaAPI DocExample1002Mon May 01 14:42:04 BST 2000None

NoisyButton

public class NoisyButton extends JFrame

Fields Summary
Constructors Summary
public NoisyButton(AudioClip sound)

    // set up the frame
    setTitle("NoisyButton");
    addWindowListener(new WindowAdapter(  ) {
      public void windowClosing(WindowEvent e) { System.exit(0); }
    });
    setSize(200, 200);
    setLocation(100, 100);
    // set up the button
    JButton button = new JButton("Woof!");
    button.addActionListener(new ActionListener(  ) {
      public void actionPerformed(ActionEvent e) { sound.play(  ); }
    });
    getContentPane(  ).setBackground(Color.pink);
    getContentPane().setLayout(new GridBagLayout(  ));
    getContentPane(  ).add(button);
    setVisible(true);
  
Methods Summary
public static voidmain(java.lang.String[] args)

    java.io.File file = new java.io.File("bark.aiff");
    AudioClip sound = Applet.newAudioClip(file.toURL(  ));
    new NoisyButton(sound);