2012-03-05 70 views
-1

我有一個位圖字段在我的blackberry5應用程序與fieldChanged監聽器連接到它,它工作絕對精細 現在我的問題是,我也有一個相同的目的相關的菜單(我不能刪除它的要求),並點擊我得到的菜單中選擇一個JVM 104 IllegalStateException異常黑莓位圖fieldChanged拋出IllegalStateException

這裏是我的菜單類

public class TabMenu extends MenuItem{ 
    MainScreen menuScreen; 
    Field button; 
    public TabMenu(String menuLabel,MainScreen menuScreen,Field button) 
    { 

     super(menuLabel, 1, 0); 
     this.menuScreen = menuScreen; 
     this.button = button; 
    }//end constructor 



    public void run() 
    { 
     FieldChangeListener listener = (FieldChangeListener)this.menuScreen; 
     listener.fieldChanged(this.button, this.button.getIndex()); 
     this.button.setFocus(); 

    } 

} 

,這裏是菜單和fieldchnaged代碼

protected void makeMenu(Menu menu, int instance) { 
    menu.add(new RefreshMenu()); 
    menu.addSeparator(); 
    menu.add(new TabMenu("Go >", this, goTab)); 
    menu.addSeparator(); 
} 


    public void fieldChanged(Field field, int context) { 
    if (field == goTab) { 
     Dialog.alert("goinf") 
    } 
} 
+0

任何建議,提示或建議,請 – 2012-03-05 11:59:27

+0

和內部fieldChanged(場,上下文) – 2012-03-05 12:21:32

+0

代碼保護無效列出MakeMenu(菜單菜單,詮釋實例){ \t \t \t \t menu.add(new RefreshMenu()); \t \t menu.addSeparator(); (新的TabMenu(「Go>」,this,goTab)); \t \t menu.addSeparator(); \t \t \t } 公共無效fieldChanged(場場,INT上下文){ \t \t \t 如果(場== goTab) \t { \t \t Dialog.alert( 「goinf」) \t} } – 2012-03-05 12:22:07

回答

0

試着改變你的TabMenu#run()方法如下:

public void run() { 
    this.button.fieldChangedNotify(this.button.getIndex()); 
    this.button.setFocus(); 
}