给你一段applet的吧
/*
* @(#)SimplePlayer.java 1.0 04/09/12
*
* You can modify the template of this file in the
* directory ..\JCreator\Templates\Template_2\Project_Name.java
*
* You can also create your own project template by making a new
* folder in the directory ..\JCreator\Template\. Use the other
* templates as examples.
*
*///<applet code=SimplePlayer1 width=200 height=50>
//</applet>
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.net.*;
import java.applet.*;
import java.applet.Applet;public class SimplePlayer extends JApplet
{
AudioClip audio1;
JLabel playtitle=new JLabel("---------------PlaySound--------------");
JButton
button1=new JButton("Play"),
button2=new JButton("Stop"),
button3=new JButton("Repeat");
JPanel panel=new JPanel();
class Button1Listner implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
audio1.play();
}
}
class Button2Listner implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
audio1.stop();
}
}
class Button3Listner implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
audio1.loop();
}
}
Button1Listner a1=new Button1Listner();
Button2Listner a2=new Button2Listner();
Button3Listner a3=new Button3Listner(); public void init()
{
button1.addActionListener(a1);
button2.addActionListener(a2);
button3.addActionListener(a3);
Container cp=getContentPane();
cp.setLayout(new GridLayout(3,3));
audio1=this.getAudioClip(this.getCodeBase(),"tada.wav");
Component c=new Component(){
public void paint(Graphics g){
super.paint(g);
ImageIcon i=new ImageIcon("a.gif");
i.paintIcon(this,g,0,0);
}
};
cp.add(c);
cp.add(playtitle);
cp.add(button1);
cp.add(button2);
cp.add(button3);
}
}
/*
* @(#)SimplePlayer.java 1.0 04/09/12
*
* You can modify the template of this file in the
* directory ..\JCreator\Templates\Template_2\Project_Name.java
*
* You can also create your own project template by making a new
* folder in the directory ..\JCreator\Template\. Use the other
* templates as examples.
*
*///<applet code=SimplePlayer1 width=200 height=50>
//</applet>
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.net.*;
import java.applet.*;
import java.applet.Applet;public class SimplePlayer extends JApplet
{
AudioClip audio1;
JLabel playtitle=new JLabel("---------------PlaySound--------------");
JButton
button1=new JButton("Play"),
button2=new JButton("Stop"),
button3=new JButton("Repeat");
JPanel panel=new JPanel();
class Button1Listner implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
audio1.play();
}
}
class Button2Listner implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
audio1.stop();
}
}
class Button3Listner implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
audio1.loop();
}
}
Button1Listner a1=new Button1Listner();
Button2Listner a2=new Button2Listner();
Button3Listner a3=new Button3Listner(); public void init()
{
button1.addActionListener(a1);
button2.addActionListener(a2);
button3.addActionListener(a3);
Container cp=getContentPane();
cp.setLayout(new GridLayout(3,3));
audio1=this.getAudioClip(this.getCodeBase(),"tada.wav");
Component c=new Component(){
public void paint(Graphics g){
super.paint(g);
ImageIcon i=new ImageIcon("a.gif");
i.paintIcon(this,g,0,0);
}
};
cp.add(c);
cp.add(playtitle);
cp.add(button1);
cp.add(button2);
cp.add(button3);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货