// 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);