Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MusicApplet.java
Package: applet_music_player.rar [view]
Upload User: yunshuzx
Upload Date: 2022-04-09
Package Size: 3k
Code Size: 2k
Category:
Applet
Development Platform:
Java
- import java.io.*;
- import java.awt.*;
- import java.applet.*;
- import java.awt.event.*;
- public class MusicApplet extends Applet implements ActionListener{
- Button b_play, b_loop, b_stop;
- TextArea ta;
- List list;
- //audio
- AudioClip audioClip;
- public void init() {
- //html
- String filenames = getParameter("filelist");
- String fileList[] = filenames.split(" ");
- //下层panel
- b_play = new Button("Play");
- b_play.addActionListener(this);
- b_loop = new Button("Loop");
- b_loop.addActionListener(this);
- b_stop = new Button("Stop");
- b_stop.addActionListener(this);
- Panel panel_button = new Panel();
- panel_button.setLayout(new FlowLayout());
- panel_button.add(b_play);
- panel_button.add(b_loop);
- panel_button.add(b_stop);
- //中间panel
- ta = new TextArea();
- list = new List(5, false);
- list.addActionListener(this);
- for (int i = 0; i < fileList.length; i++) {
- list.add(fileList[i]);
- }
- Panel panel_text = new Panel();
- panel_text.setLayout(new GridLayout(1, 2));
- panel_text.add(list);
- panel_text.add(ta);
- //applet
- setLayout(new BorderLayout());
- add(panel_button, "South");
- add(panel_text, "Center");
- audioClip=getAudioClip(getCodeBase());
- }
- public void actionPerformed(ActionEvent e) {
- Object obj = e.getSource();
- if (obj == list) {
- String s = list.getSelectedItem();
- File file = new File(s);
- if (file.exists()) {
- audioClip=getAudioClip(getCodeBase(), s);
- ta.setText(s + " is opened successfully");
- audioClip.loop();
- }
- else {
- ta.setText(s + " doesn't exist, please choose another one");
- }
- }
- else if (obj == b_play) {
- audioClip.play();
- }
- else if (obj == b_loop) {
- audioClip.loop();
- }
- else if (obj == b_stop) {
- audioClip.stop();
- }
- }
- }