java 出现问题——只有缩小化窗口才播放音乐。不知道哪里错了
importjava.awt.*;importjava.applet.*;importjava.awt.event.*;classMusicextendsThread{A...
import java.awt.*;import java.applet.*;import java.awt.event.*;class Music extends Thread{ AudioClip bgMusic; boolean playMusic; public Music(Applet Game) { playMusic = true; } public void run() { if(playMusic == true) bgMusic.loop(); else bgMusic.stop(); }} public class LMusic extends Applet implements Runnable,ItemListener{ Thread newThread; Checkbox CMusic; Music music; int count; public void init() { count = 0; CMusic = new Checkbox("音乐",true); add(CMusic); CMusic.addItemListener(this); music = new Music(this); music.bgMusic = getAudioClip(getDocumentBase(),"voise/疯狂.MID"); } public void start() { newThread = new Thread(this); newThread.start(); } public void run() { while(newThread != null) { music.run(); } } public void stop() { newThread = null; } public void itemStateChanged(ItemEvent e) { count++; if(e.getStateChange()== ItemEvent.SELECTED) { music.playMusic = true; } else { music.playMusic = false; } System.out.println("点击 "+count+" 次"); }}
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询