0 votes
in Computers & Internet by (150 points)

因專題需求

需要點下按鈕或點選下拉式選單後即播放某個音檔的程式

請問我該如何作?

Update:

可以順便請你給我ISBN碼嗎

495 Answers

0 votes
by (440 points)
 
Best answer

import java.awt.*;

import java.applet.Applet;

import java.applet.AudioClip;

import java.awt.event.*;

public class my_music extends Applet implements ItemListener{

Choice cho=new Choice();

AudioClip clip ,music[]=new AudioClip[5];

public void init(){

music[0]=getAudioClip(getCodeBase(),"my_music1.midi");

music[1]=getAudioClip(getCodeBase(),"my_music2.midi");

music[2]=getAudioClip(getCodeBase(),"my_music3.midi");

music[3]=getAudioClip(getCodeBase(),"my_music4.midi");

music[4]=getAudioClip(getCodeBase(),"my_music5.midi");

cho.add("musicA");

cho.add("musicB");

cho.add("musicC");

cho.add("musicD");

cho.add("musicE");

add(cho);

cho.addItemListener(this);

clip=music[0];

clip.play(); }

public void itemStateChanged(ItemEvent e){

clip.stop();

clip=music[cho.getSelectedIndex()];

clip.play(); } }

/*

<HTML>

<BODY BGCOLOR = "AAFFFF" >

<APPLETCODE = "my_music.class"WIDTH = "40"HEIGHT = "20" >

</APPLET>

</BODY>

</HTML>

*/

2007-11-15 20:52:47 補充:

本程式的 .midi 是用

windows media player

去開啟的 .......(個人感覺)

參考資料是JAVA2 博碩出版

2007-11-20 20:05:23 補充:

ISBN碼是 957-527-471-7

2007-11-23 20:12:15 補充:

這支程式碼 測試是成功的.先決條件是必須在.class 檔的同一資料夾,置入名為 my_music1.midi;my_music2.midi;my_music3.midi;my_music4.midi;my_music5.midi 的音樂檔.

0 votes
by
0 votes
by
<a href=http://buystromectolon.com/>ivermectin for humans amazon</a>
0 votes
by
0 votes
by
Kamagra Kaufen Forum
0 votes
by
0 votes
by
0 votes
by
http://buypropeciaon.com/ - propecia generic name
0 votes
by
<a href=http://buysildenshop.com/>viagra email spam</a>
0 votes
by
Alli Diet Pills India Pharmacy
Welcome to zKusimused Q&A, where you can ask questions and receive answers from other members of the community.
...