⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example8_16.java.bak

📁 书中的例题
💻 BAK
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -