| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 521 人关注过本帖
标题:照着书打的一个简单的音乐播放器,可编译时告诉我api过时,麻烦大神们能看一 ...
只看楼主 加入收藏
icanbestrong
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:100
专家分:138
注 册:2013-3-13
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:1 
照着书打的一个简单的音乐播放器,可编译时告诉我api过时,麻烦大神们能看一看
import java.awt.*;
import *;
import java.awt.event.*;
import *;
import java.applet.*;
class AudioClipWindow extends Frame
implements Runnable,ItemListener,ActionListener
{Thread thread;
Choice choice;
URL url;
AudioClip clip;
Button buttonPlay,buttonLoop,buttonStop;
String str;
AudioClipWindow(){
thread=new Thread(this);
choice=new Choice();
choice.add("hey jude.wav");
choice.add("hole(live).wav");
choice.addItemListener(this);
buttonPlay=new Button("play");
buttonLoop=new Button("loop");
buttonStop=new Button("stop");
buttonPlay.addActionListener(this);
buttonLoop.addActionListener(this);
buttonStop.addActionListener(this);
setLayout(new FlowLayout());
add(choice);
add(buttonPlay);
add(buttonLoop);
add(buttonStop);
setSize(350,120);
setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{System.exit(0);
}
});
validate();
}
public void itemStateChanged(ItemEvent e){
str=choice.getSelectedItem();
if(!(thread.isAlive())){
thread=new Thread(this);
}
try{
thread.start();
}
catch(Exception ee){
}
}
public void run(){
try{File file=new File(str);
url=file.toURL();
clip=Applet.newAudioClip(url);
}
catch(Exception e){
System.out.println(e);
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==buttonPlay){
clip.play();}
else if(e.getSource()==buttonLoop){
clip.loop();}
if(e.getSource()==buttonStop){
clip.stop();}
}
}
public class qq{
public static void main(String args[]){
AudioClipWindow win=new AudioClipWindow();
}
}
去SUN公司查了一下api都有啊,麻烦能抽空看一下
搜索更多相关主题的帖子: 音乐播放器 thread Choice choice import 
2013-11-07 20:15
ren829
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:15
帖 子:255
专家分:1174
注 册:2006-3-11
收藏
得分:20 
java为了向下兼容老版本,就算是过时的api也是提供支持的,并没有废止,不过都不推荐用过时的方法了。
2013-11-07 20:55
快速回复:照着书打的一个简单的音乐播放器,可编译时告诉我api过时,麻烦大神们 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017191 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved