求 JAVA APPLET语音聊天室&&APPLET 播放歌曲代码 各位谁弄过 APPLET 实现语音聊天室&&APPLET播放 歌曲(MP3,WAV,RM,MPEG) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.*;import java.awt.event.*;import java.applet.Applet;import java.applet.AudioClip;public class PlayMedia extends Applet{ Image testImage; AudioClip audio; public void init () { Button btnPlay = new Button ("Play"); Button btnStop = new Button ("Stop"); add (btnPlay); add (btnStop); try { testImage = getImage (getDocumentBase (), "house2.gif"); audio = getAudioClip (getDocumentBase (), "onestop.mid"); } catch (Exception e) { System.out.println (e.toString ()); } btnPlay.addActionListener(new ActionListener () { public void actionPerformed (ActionEvent e) { try { audio.play (); } catch (Exception err) { System.out.println (err.toString ()); } } }); btnStop.addActionListener (new ActionListener () { public void actionPerformed (ActionEvent e) { try { audio.stop (); } catch (Exception err) { System.out.println (err.toString ()); } finally { } } }); } public void paint (Graphics g) { g.drawImage (testImage, 0, 0, this); } // public boolean mouseDown (Event evt, int x, int y)// {// audio.play ();// System.out.println("dddd");// return true;// }} Java本身就可以播放mp3,wav等几种简单的声音文件。有类可以直接用的。 我用这个怎么不行?是不是不能用.mp3格式?还是路径不对?audio=getAudioClip(getDocumentBase(),"1.mp3"); 多线程问题 求助:java socket多线程问题! java中用poi操作word时报的异常求教 JtabbedPane 如何改变标签形状? 怎么把一个Socket服务端的输出流结束(服务端与客户端双向通信问题),即避免客户端阻塞. 如何去掉不能识别的utf-8编码的字符 ASK:AWT里的peer到底是什么概念?? jboss好不好? EntityBean效率低吗? java如何构造一个函数(是不是一个类阿?),和属性; 在jcreator如何调试? 求助!applet在jb里好好的,加到网页里不响应按钮事件?
import java.awt.event.*;
import java.applet.Applet;
import java.applet.AudioClip;public class PlayMedia extends Applet
{
Image testImage;
AudioClip audio;
public void init ()
{
Button btnPlay = new Button ("Play");
Button btnStop = new Button ("Stop");
add (btnPlay);
add (btnStop);
try
{
testImage = getImage (getDocumentBase (), "house2.gif");
audio = getAudioClip (getDocumentBase (), "onestop.mid");
}
catch (Exception e)
{
System.out.println (e.toString ());
}
btnPlay.addActionListener(new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
try
{
audio.play ();
}
catch (Exception err)
{
System.out.println (err.toString ());
}
}
});
btnStop.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
try
{
audio.stop ();
}
catch (Exception err)
{
System.out.println (err.toString ());
}
finally
{
}
}
});
}
public void paint (Graphics g)
{
g.drawImage (testImage, 0, 0, this);
}
// public boolean mouseDown (Event evt, int x, int y)
// {
// audio.play ();
// System.out.println("dddd");
// return true;
// }
}
audio=getAudioClip(getDocumentBase(),"1.mp3");