日期:2014-05-20  浏览次数:20749 次

谁知道错在那里啊?
import   javax.microedition.midlet.*;
import   javax.microedition.lcdui.*;
import   javax.microedition.media.*;

/**
  *
  *   @author     Admin
  *   @version
  */
public   class   PlayToneDemo   extends   MIDlet   implements   CommandListener{
        private     Display   display;
        Form   form   =   new   Form( "音调播放演示 ");
        TextField   tfNote   =   new   TextField( "请输入音量(0-127) ", "49 ",3,
                        TextField.NUMERIC);
        TextField   tfDuration   =   new   TextField( "请输入持续时间(毫秒) ", "1000 ",10,
                        TextField.NUMERIC);
        Gauge   gagVol   =   new   Gauge( "请选择音量 ",true,100,80);
        private   Command   cmdPlay   =   new   Command( "播放 ",Command.OK,1);
        private   Command   cmdExit   =   new   Command( "退出 ",Command.STOP,1);
        public   void   PlayToneDemo(){
                gagVol.setLayout(Item.LAYOUT_EXPAND);
                form.append(tfNote);
                form.append(tfDuration);
                form.append(gagVol);
                form.addCommand(cmdPlay);
                form.addCommand(cmdExit);
                form.setCommandListener(this);
        }
        public   void   commandAction(Command   c,Displayable   d){
                String   label   =   c.getLabel();
                if   (label.equals( "退出 ")){
                        this.notifyDestroyed();
                }
                if   (label.equals( "播放 ")){
                        int   note   =   Integer.parseInt(this.tfNote.getString());
                        if   ((note> =0)&&(note <=127)){
                                int   duration   =   Integer.parseInt(this.tfDuration.getString());
                                int   vol   =   this.gagVol.getValue();
                                try{
                                        javax.microedition.media.Manager.playTone(note,duration,vol);