FileDocCategorySizeDatePackage
NoisyButton.javaAPI DocExample865Sat Apr 23 22:35:40 BST 2005None

NoisyButton

public class NoisyButton extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    JFrame frame = new JFrame("NoisyButton");
    java.io.File file = new java.io.File( args[0] );
    final AudioClip sound = Applet.newAudioClip(file.toURL(  ));

    // set up the button
    JButton button = new JButton("Woof!");
    button.addActionListener(new ActionListener(  ) {
      public void actionPerformed(ActionEvent e) { sound.play(  ); }
    });

	Container content = frame.getContentPane();
    content.setBackground(Color.pink);
    content.setLayout(new GridBagLayout());
    content.add(button);
    frame.setVisible(true);
    frame.setSize(200, 200);
	frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
	frame.setVisible(true);