用一个JAVA小应用程序来显示一个按钮,一个图片再加一段音乐。有的帮忙写一下。谢谢。 25
1个回答
展开全部
import java.awt.*;
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.event.*;
public class multiMedia extends Applet{
AudioClip sound;
Image image;
Button invoke;
public void init() {
Button invoke = new Button();
AppletExample a=new AppletExample();
sound = getAudioClip(getCodeBase(), "Sound/m2.mid");
image = getImage(getCodeBase(),"/image/background.bmp");
this.add(invoke);
}
public void start() {
sound.loop();
}
public void stop() {
sound.stop();
}
public void paint(Graphics g) {
g.drawRect(0,0,50,50);
Graphics copy = getGraphics();
try {
copy.drawImage(image, this.getWidth()+30, this.getHeight()+20, this);
} finally {
copy.dispose();
}
}
}
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.event.*;
public class multiMedia extends Applet{
AudioClip sound;
Image image;
Button invoke;
public void init() {
Button invoke = new Button();
AppletExample a=new AppletExample();
sound = getAudioClip(getCodeBase(), "Sound/m2.mid");
image = getImage(getCodeBase(),"/image/background.bmp");
this.add(invoke);
}
public void start() {
sound.loop();
}
public void stop() {
sound.stop();
}
public void paint(Graphics g) {
g.drawRect(0,0,50,50);
Graphics copy = getGraphics();
try {
copy.drawImage(image, this.getWidth()+30, this.getHeight()+20, this);
} finally {
copy.dispose();
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询