首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2ME开发 >

哪位高手知道错在那里啊

2012-03-17 
谁知道错在那里啊?importjavax.microedition.midlet.*importjavax.microedition.lcdui.*importjavax.mic

谁知道错在那里啊?
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);


                                       
                                       
                                }catch   (exception   e){
                                        System.out.println( "播放声调发生异常: "   +   e.toString());
                                }
                        }
                        public   void   startApp()   {
                               
                                Display.getDisplay(this).setCurrent(form);
                                  PlayToneDemo();
                               
                               
                        }
                       
                        public   void   pauseApp()   {
                        }
                       
                        public   void   destroyApp(boolean   unconditional)   {
                                this.notifyDestroyed();
                        }
                }
        }    
}
C:\Documents   and   Settings\Admin\MobileApplication1\src\PlayToneDemo.java:53:   非法的表达式开始
                        public   void   startApp()   {
C:\Documents   and   Settings\Admin\MobileApplication1\src\PlayToneDemo.java:68:   需要为   class   或   interface
        }    
2   错误
C:\Documents   and   Settings\Admin\MobileApplication1\nbproject\build-impl.xml:183:   Compile   failed;   see   the   compiler   error   output   for   details.
生成失败(总时间:2   秒)


[解决办法]
public void PlayToneDemo()
构造函数不需返回类型.
[解决办法]
废话,startApp()pauseApp()destroyApp(boolean unconditional)都没了,你的程序入口出口在哪??


[解决办法]
方法没有正确结束,缺}:

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);


}catch (exception e){
System.out.println( "播放声调发生异常: " + e.toString());
}
}
}}
public void startApp() {

Display.getDisplay(this).setCurrent(form);
PlayToneDemo();
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
this.notifyDestroyed();
}
}
[解决办法]
大家好,我以前也是学做JAVA,最近觉得很累就转行了,现在在卖国产手机,主要是卖高仿品(比如诺基亚N73,N70)等等。我知道程序员很多时候都不怎么想出去玩,逛街等等。。所以给大家提个方便,这个不是广告。
最近有一个朋友进了一批全新库存戴尔笔记本电脑,型号:5100/5150/5160/1100
价格是2600元 RMB 如有需求请和我联系。我在深圳,QQ号码是50348744.邮箱是lixudong3032@126.com

热点排行