example8_16.java.bak

来自「书中的例题」· BAK 代码 · 共 52 行

BAK
52
字号
import sun.audio.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;

class Sound 
{
 FileInputStream file;
 BufferedInputStream buf;
  public Sound()
   {
    try 
      {
         file=new FileInputStream("披着羊皮的狼.wav");
		 buf=new BufferedInputStream(file);
         AudioStream audio=new AudioStream(buf);
         AudioPlayer.player.start(audio);
      }
    catch (Exception e) {}
   }
}

public class Example8_16 extends Frame implements ActionListener 
{
   Example8_16()
	{
	  super("音频播放器");
	  setBounds(300,300,200,100);
	  setVisible(true);
	  Button btn=new Button("播放");
	  setLayout(new FlowLayout());
	  add(btn);
	  btn.addActionListener(this);
	  validate();
	  addWindowListener(new WindowAdapter()
         {  public void windowClosing(WindowEvent e)
              { System.exit(0);
               } 
            });
	}

 public void actionPerformed(ActionEvent e)
   {
	 Sound play = new Sound();
   }

  	public static void main(String[] args) 
	{
		 new Example8_16();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?