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

📄 playsound.java

📁 how to make a game using java.
💻 JAVA
字号:
//PlaySound.java
//[Imperial Snowman Soft]

import java.awt.*;
import java.awt.event.*;
import java.applet.*;


public class PlaySound extends Applet implements ActionListener
{ 


	Button playbutton;
	Button stopbutton;
	AudioClip soundclip;


	public void init()

	//The init() method of an applet
	{
		super.init();
		playbutton = new Button("Play");
		playbutton.addActionListener(this); //Add to the ActionListener
		add(playbutton);
		stopbutton = new Button("Stop");
		stopbutton.addActionListener(this); //Add to the ActionListener
		add(stopbutton);
		soundclip = getAudioClip(getCodeBase(),"blitz.au");
	} 

	public void actionPerformed(ActionEvent event) //The event method
	{

		String cmd = event.getActionCommand(); //get the ActionCommand
		if (cmd.equals("Play"))
		{
			soundclip.loop();
		}
		else if (cmd.equals("Stop"))
		{
			soundclip.stop();
		}
	} 

}

⌨️ 快捷键说明

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