setTitle( "Sound Application" );
JMenuBar mb = new JMenuBar();
this.setJMenuBar( mb );
JMenu f = new JMenu( "File" );
mb.add( f );
JMenuItem open = new JMenuItem( "Open" );
open.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e )
{ getFile();
SoundApp.this.repaint(); // messy!
}
});
JMenuItem exit = new JMenuItem( "Exit" );
exit.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e )
{ dispose();
System.exit(0);
}
});
f.add( open );
f.add( new JSeparator() );
f.add( exit );
this.getContentPane().add( url, BorderLayout.NORTH );
url.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent e )
{ getAudioClip();
}
});
JPanel buttons = new JPanel();
this.getContentPane().add( buttons, BorderLayout.SOUTH );
JButton play = new JButton( "Play" );
play.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent e )
{ if( clip != null );
clip.play();
}
});
buttons.add( play );
JButton loop = new JButton( "Loop" );
loop.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent e )
{ if( clip != null );
clip.loop();
}
});
buttons.add( loop );
JButton stop = new JButton( "Stop" );
stop.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent e )
{ if( clip != null );
clip.stop();
}
});
buttons.add( stop );
this.addWindowListener( new WindowAdapter(){
public void windowClosing(WindowEvent e)
{ dispose();
System.exit(0);
}
});