📄 playsound.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 + -