I have created an Alert dialog box in my J2ME app to alert user when user press exit button to terminate an app & ask user confirmation to exit from app with yes and no command.when user press Yes button app will terminate and when user press No button app will return to its Main form. To do this I develop a code from scratch which are as follows :-

Code:
public class CustomAlert extends MIDlet implements CommandListener  
{
        Alert ExitAlrt;
        Display d;
        Command MainListSelect, Exit, YesCmdAlrt, NoCmdAlrt;
        List MainList;
        
	public CustomAlert()
	{
                d = Display.getDisplay(this);
		
                //Initialization of commands
		MainListSelect = new Command("Select", Command.SCREEN, 1);
		Exit = new Command("Exit", Command.STOP, 2);
                
		//Initialization of lists
		MainList = new List("Menu", List.IMPLICIT);
                       
                //Adding command to lists
		MainList.addCommand(MainListSelect);
		MainList.addCommand(Exit);
		MainList.setCommandListener(this);
                
               //Appending the content of lists
		MainList.append("Reminder List",null);
		MainList.append("Settings",null);          
        }
    protected void startApp()
    {   
        MainList.setSelectedIndex(0, true);
        d.setCurrent(MainList);
    }
    protected void pauseApp() { }
    protected void destroyApp(boolean unconditional)
    {}
    
    public void commandAction(Command cmd,Displayable dispable) // This method handle commands which operate list that is Select & Exit
    {
        if(cmd == MainListSelect)
        {
            int slctindx = MainList.getSelectedIndex();
            if(slctindx == 0)
            {
                
            }
            else if(slctindx == 1)
            {
               
            } 
        }
       
         if(cmd == Exit)
        {
            ExitAlrt = new Alert("Application Alert","Are you sure you want to exit?",null, AlertType.WARNING);
            YesCmdAlrt = new Command("Yes", Command.EXIT,1);
            ExitAlrt.addCommand(YesCmdAlrt); 
            NoCmdAlrt = new Command("No", Command.SCREEN,2);
            ExitAlrt.addCommand(NoCmdAlrt);
            d.setCurrent(ExitAlrt);
        }
    }
    
    public void commandAction(Command cmd)  // This Code handle Commands present on Alert dialog box. 
    {
            ExitAlrt.setCommandListener(this);
            if(cmd == NoCmdAlrt)
            {
                d.setCurrent(MainList);
            }
            else if(cmd == YesCmdAlrt)
            {   
                destroyApp(true);
                notifyDestroyed();
            }
     }
}
In above code problem is when I click on Exit button, Alert box appears & when I press Yes button to terminate an app it again redirect to me on Main List of an app...... I did lot of placements in code but problem remain constant....... I hope you understood my problem.... Now what is solution for this? I am still working on this.