import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.net.*; import java.applet.*; public class music extends JFrame implements ActionListener { private JButton play=new JButton('Play'); private JButton stop=new JButton('Stop'); private JPanel outer=new JPanel(); AudioClip clip; public music() { super('music'); Container container=getContentPane(); outer.setBackground(Color.white); outer.setLayout(null); container.add(outer); outer.add(play); outer.add(stop);//一定要放在setsize之前 play.setBounds(30,350,60,30); stop.setBounds(30,400,60,30); setSize(500,520); setVisible(true); setResizable(false); play.addActionListener(this); stop.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==play) { try { File file=new File('001001.mid'); clip=Applet.newAudioClip(file.toURL()); clip.loop(); }catch(MalformedURLException ex){} } else if(e.getSource()==stop) { clip.stop(); } } public static void main(String args[]) { music app=new music(); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }"