📄 audioapplet.java
字号:
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.applet.AudioClip;
public class AudioApplet extends Applet implements ItemListener, ActionListener
{
AudioClip sound;
Choice c=new Choice ();
Button play=new Button ("播放" );
Button loop=new Button ("循环" );
Button stop=new Button ("停止" );
public void init ()
{
c. add ("music1.wav" );
c. add ("music2.wav" );
add (c );
c. addItemListener (this);
add (play);
add (loop );
add (stop);
play. addActionListener (this);
loop. addActionListener (this);
stop. addActionListener (this);
sound=getAudioClip (getCodeBase (),"music1.wav");
}
public void itemStateChanged (ItemEvent e)
{
sound.stop ();
sound=getAudioClip (getCodeBase (), c. getSelectedItem () );
}
public void actionPerformed (ActionEvent e )
{
if (e.getSource () ==play)
sound. play ();
if (e.getSource () ==loop)
sound. loop ();
if (e.getSource () ==stop )
sound. stop ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -