Java me LUIT:需要帮助'Back'命令工作不正常

Java me LUIT:需要帮助'Back'命令工作不正常,java-me,lwuit,Java Me,Lwuit,我们使用表单显示一个启动屏幕,然后是菜单表单,其中包含许多按钮,如关于我们、登录、反馈等。 现在,我转到包含菜单和返回命令的登录表单。我的问题是,在此表单中单击back命令时,会转到SPLASH屏幕 预期的行为是LOGIN表单中的back命令必须返回菜单表单,而不是SPLASH表单 如何做到这一点 Splash.java public class Splash extends MIDlet implements ActionListener { Image img_Splash;

我们使用表单显示一个启动屏幕,然后是菜单表单,其中包含许多按钮,如关于我们、登录、反馈等。 现在,我转到包含
菜单
返回
命令的
登录
表单。我的问题是,在此表单中单击
back
命令时,会转到
SPLASH
屏幕

预期的行为是
LOGIN
表单中的back命令必须返回
菜单
表单,而不是
SPLASH
表单

如何做到这一点

Splash.java

public class Splash extends MIDlet implements ActionListener {
    Image img_Splash;
    Form frm_Main;
    String str_URL;
    int Width, Height;
    Label lbl_Splash;
    Command cmd_Cancel;

    public void startApp() {
        Display.init(this);

        frm_Main = new Form();
        try {
            //Resources theme = Resources.open("/44444.res");
            img_Splash = Image.createImage("/res/splash.png");
            Resources theme = Resources.open("/666666.res");
            UIManager.getInstance().setThemeProps(
                    theme.getTheme(theme.getThemeResourceNames()[0]));
        } catch (IOException io) {
            io.printStackTrace();
            Dialog.show("Theme Exception", io.getMessage(), "Ok", null);
        }


        lbl_Splash = new Label(img_Splash);
        lbl_Splash.getStyle().setBgColor(16777215);

        frm_Main.addComponent(lbl_Splash);
        frm_Main.setScrollable(true);

        cmd_Cancel = new Command("Cancel");
        frm_Main.addCommand(cmd_Cancel);
        frm_Main.addCommandListener(this);

        frm_Main.show();

        // th
        Thread splashThread = new Thread() {

            public void run() {
                try {
                    sleep(5000);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();

                } finally {
                    MainMenu mainmenu = new MainMenu(frm_Main);
                    mainmenu.show();
                }
            }
        };
        splashThread.start();
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        //notifyDestroyed();
    }

    public void actionPerformed(ActionEvent ae) {
        Command con = ae.getCommand();
        String str_CmdName = con.getCommandName();

        if (str_CmdName.equals("Cancel")) {
            notifyDestroyed();
        }
    }
}
class MainMenu extends Form implements ActionListener {

    Form frm_Main;
    //MainMidlet main;
    public Button btn_main_Login, btn_main_NewUser, btn_main_Help;
    public Label lbl_main_Login, lbl_main_NewUser, lbl_main_Help;

    public Image img_main_Login, img_main_NewUser, img_main_Help;
    public Command cmd_Exit, cmd_Select;

    public MainMenu(Form form) {
        this.frm_Main = form;
        try {
            img_main_Login = Image.createImage("/res/btn_main_login.png");
            img_main_NewUser = Image.createImage("/res/btn_main_newuser.png");
            img_main_Help = Image.createImage("/res/btn_main_help.png");
        } catch (IOException io) {
            io.printStackTrace();
            //Dialog.show("Image not Found!", io.getMessage(), "Ok", null);
            System.out.println("Image not found" + io.getMessage());
        }


        //---------   Whole form define as BorderLayout with three Container.
        BorderLayout bor_MainMenuLayout = new BorderLayout();
        setLayout(bor_MainMenuLayout);
        setScrollable(false);

        //----------- Define Container for Header On North
        Container con_Header = new Container();
        lbl_Header = new Label(img_Header);
        con_Header.addComponent(lbl_Header);


        //----------- Define Container as GridLayout and place
        //----------- on BorderLayout Center position
        //---------     Define Container(CENTER) for search details
        //---------     with BoxLayout
        BoxLayout bx_CenterLayout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Center = new Container(bx_CenterLayout);
        con_Center.setScrollableY(true);
        con_Center.getStyle().setPadding(0, 10, 3, 3);

        //---------     FlowLayout for Header Details
        FlowLayout flw_MenuHdr = new FlowLayout();
        Container con_HdrDetails = new Container(flw_MenuHdr);
        lbl_MenuHdr = new Label("Menu");
        lbl_MenuHdr.getStyle().setBgTransparency(0);
        lbl_MenuHdr.getStyle().setPadding(0, 5, 10, 0);

        con_HdrDetails.addComponent(lbl_MenuHdr);

        con_Center.addComponent(con_HdrDetails);

        //----------        GridLayout define 1 rows and 3 coloumn
        //----------        First row
        GridLayout grd_Row1Layout = new GridLayout(1, 3);
        Container con_Row1Layout = new Container(grd_Row1Layout);

        btn_main_Login = new Button(img_main_Login);
        btn_main_Help = new Button(img_main_Help;
        btn_main_NewUser = new Button(img_main_NewUser);

        con_Row1Layout.addComponent(btn_main_Login);
        con_Row1Layout.addComponent(btn_main_Help);
        con_Row1Layout.addComponent(btn_main_NewUser);

        con_Center.addComponent(con_Row1Layout);



        //-----------   Add Command on softkey 
        cmd_Exit = new Command("Exit");
        cmd_Select = new Command("Select");

        addCommand(cmd_Select);
        addCommand(cmd_Exit);
        addCommandListener(this);

        addComponent(BorderLayout.NORTH, con_Header);
        addComponent(BorderLayout.CENTER, con_Center);

        //this.getStyle().setBgColor(12105912);
        frm_Main.getStyle().setBgColor(12105912);

    }

    public void actionPerformed(ActionEvent ae) {
        Command cmd = ae.getCommand();
        String str_CmdName = cmd.getCommandName();

        //-----------       When Click on Exit Button
        if (str_CmdName.equals("Exit")) {
            //System.exit(0);
            //frm_Main.notifyAll();
        }

        //-----------       When Click on Select Button
        if (str_CmdName.equals("Select")) {
            //-----------       When Click on Login
            if (btn_main_Login.hasFocus()) {
                String str_MemberId = GlobalClass.getInstance().getMemberId();

                if (!(str_MemberId == "" || str_MemberId == null)) {
                    SearchDiamond searchdiamond = new SearchDiamond(frm_Main);
                    searchdiamond.setTransitionInAnimator(
                            Transition3D.createRotation(800, true));
                    searchdiamond.show();
                } else {
                    Login login = new Login(frm_Main);
                    login.setTransitionInAnimator(
                            Transition3D.createRotation(800, true));
                    login.show();
                }

            }

            //-----------       When Click on New User
            if (btn_main_NewUser.hasFocus()) {
                //Dialog.show("New User", "NewUser", "Ok", null);
                NewUser newuser = new NewUser(frm_Main);
                //newuser.setTransitionInAnimator(
                        CommonTransitions.createFade(1500));
                newuser.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
                newuser.show();

            }

            //-----------       When Click on Help
            if (btn_main_Help.hasFocus()) {
                Help help = new Help(frm_Main);
                help.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
                help.show();
            }

            //-----------       When Click on Exit
            if (btn_main_Exit.hasFocus()) {
                System.exit(0);
            }

        }
    }
}
class Login extends Form implements ActionListener {

    Form frm_Main;
    Label lbl_Header, lbl_Footer, lbl_SepLine, lbl_HdrAlreadyMember, lbl_UserID, lbl_PWD,
            lbl_Blank2, lbl_Blank3, lbl_HdrNewMember, lbl_Info;
    TextField txtf_UserID, txtf_PWD;
    Button btn_Login;
    Command cmd_Back, cmd_AboutUs, cmd_Privacy;

    public Login(Form form) {
        this.frm_Main = form;

        //---------   Whole form define as BorderLayout with three Container.
        BorderLayout bor_LoginLayout = new BorderLayout();
        setLayout(bor_LoginLayout);
        setScrollable(false);

        //---------   Define Container(NORTH) for Header.
        Container con_Header = new Container();
        lbl_Header = new Label();
        con_Header.addComponent(lbl_Header);


        //---------     Define Container(CENTER) for search details 
        //---------     with BoxLayout
        BoxLayout bx_CenterLayout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Center = new Container(bx_CenterLayout);
        con_Center.setScrollableY(true);
        con_Center.getStyle().setMargin(5, 5, 0, 0);

        //---------     FlowLayout for Header Details
        FlowLayout flw_HdrLayout = new FlowLayout();
        Container con_HdrDetails = new Container(flw_HdrLayout);

        lbl_HdrAlreadyMember = new Label("Already a Member?");
        lbl_HdrAlreadyMember.setAlignment(Component.LEFT);
        con_HdrDetails.addComponent(lbl_HdrAlreadyMember);

        con_Center.addComponent(con_HdrDetails);

        //---------     BoxLayout for Login details
        BoxLayout bx_Login1Layout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Login1Details = new Container(bx_Login1Layout);
        con_Login1Details.setScrollableY(true);


        lbl_UserID = new Label("User Name:");


            txtf_UserID = new TextField("");
        txtf_UserID.setFocusable(true);
        txtf_UserID.setFocus(true);
        txtf_UserID.setConstraint(TextField.ANY);
        txtf_UserID.setInputMode("abc");

        lbl_PWD = new Label("Password:");

        txtf_PWD = new TextField("");
        txtf_PWD.setConstraint(TextField.PASSWORD);


        con_Login1Details.addComponent(lbl_UserID);
        con_Login1Details.addComponent(txtf_UserID);
        con_Login1Details.addComponent(lbl_PWD);
        con_Login1Details.addComponent(txtf_PWD);

        //---------     BoxLayout for Login Button
        FlowLayout flw_LoginBtnLayout = new FlowLayout(CENTER);
        Container con_LoginBtnDetails = new Container(
                flw_LoginBtnLayout);
        con_LoginBtnDetails.setScrollableY(true);

        btn_Login = new Button("Login");
        btn_Login.setPreferredSize(new Dimension(80, 25));
        btn_Login.setAlignment(Component.CENTER);

        con_LoginBtnDetails.addComponent(btn_Login);

        con_Login1Details.addComponent(con_LoginBtnDetails);

        con_Center.addComponent(con_Login1Details);

        //---------     BoxLayout for other Login details
        BoxLayout bx_Login2Layout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Login2Details = new Container(bx_Login2Layout);
        con_Login2Details.setScrollableY(true);
        con_Login2Details.getStyle().setMargin(5, 5, 10, 10);

        //---------     Login type 3 New Remember Me
        chk_RememberMe = new CheckBox("Remember Me");
        chk_RememberMe.setTickerEnabled(false);
        con_Login2Details.addComponent(chk_RememberMe);

        //---------     Login type 3 New Forgot Password
        btn_ForgotPWD = new Button("Forgot Password?");
        btn_ForgotPWD.setTickerEnabled(false);
        btn_ForgotPWD.setAlignment(Component.LEFT);
        btn_ForgotPWD.setTextPosition(Component.RIGHT);

        con_Login2Details.addComponent(btn_ForgotPWD);

        con_Center.addComponent(con_Login2Details);
        con_Center.getStyle().setPadding(0, 0, 10, 10);

        addComponent(BorderLayout.NORTH, con_Header);
        addComponent(BorderLayout.CENTER, con_Center);

        cmd_Back = new Command("Back");
        this.setBackCommand(cmd_Back);
        addCommand(cmd_Back);
        addCommandListener(this);


        //----------  Add More Command for Menu item
        cmd_AboutUs = new Command("About Us");
        cmd_Privacy = new Command("Privacy");

        addCommand(cmd_AboutUs);
        addCommand(cmd_Privacy);

        //-------       When Login Button is Clicked
        btn_Login.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                     ....
            }
        });
    }
    public void actionPerformed(ActionEvent ae) {
        Command con = ae.getCommand();
        String str_CmdName = con.getCommandName();
        if (str_CmdName.equals("Back")) {
            // here back code 
            frm_Main.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
            frm_Main.showBack();
        }

        ....
        if (str_CmdName.equals("About Us")) {
            AboutUs aboutus = new AboutUs(frm_Main);
            aboutus.show();
        }

        if (str_CmdName.equals("Privacy")) {
            Privacy privacy = new Privacy(frm_Main);
            privacy.show();
        }

    }
}
main menu.java

public class Splash extends MIDlet implements ActionListener {
    Image img_Splash;
    Form frm_Main;
    String str_URL;
    int Width, Height;
    Label lbl_Splash;
    Command cmd_Cancel;

    public void startApp() {
        Display.init(this);

        frm_Main = new Form();
        try {
            //Resources theme = Resources.open("/44444.res");
            img_Splash = Image.createImage("/res/splash.png");
            Resources theme = Resources.open("/666666.res");
            UIManager.getInstance().setThemeProps(
                    theme.getTheme(theme.getThemeResourceNames()[0]));
        } catch (IOException io) {
            io.printStackTrace();
            Dialog.show("Theme Exception", io.getMessage(), "Ok", null);
        }


        lbl_Splash = new Label(img_Splash);
        lbl_Splash.getStyle().setBgColor(16777215);

        frm_Main.addComponent(lbl_Splash);
        frm_Main.setScrollable(true);

        cmd_Cancel = new Command("Cancel");
        frm_Main.addCommand(cmd_Cancel);
        frm_Main.addCommandListener(this);

        frm_Main.show();

        // th
        Thread splashThread = new Thread() {

            public void run() {
                try {
                    sleep(5000);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();

                } finally {
                    MainMenu mainmenu = new MainMenu(frm_Main);
                    mainmenu.show();
                }
            }
        };
        splashThread.start();
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        //notifyDestroyed();
    }

    public void actionPerformed(ActionEvent ae) {
        Command con = ae.getCommand();
        String str_CmdName = con.getCommandName();

        if (str_CmdName.equals("Cancel")) {
            notifyDestroyed();
        }
    }
}
class MainMenu extends Form implements ActionListener {

    Form frm_Main;
    //MainMidlet main;
    public Button btn_main_Login, btn_main_NewUser, btn_main_Help;
    public Label lbl_main_Login, lbl_main_NewUser, lbl_main_Help;

    public Image img_main_Login, img_main_NewUser, img_main_Help;
    public Command cmd_Exit, cmd_Select;

    public MainMenu(Form form) {
        this.frm_Main = form;
        try {
            img_main_Login = Image.createImage("/res/btn_main_login.png");
            img_main_NewUser = Image.createImage("/res/btn_main_newuser.png");
            img_main_Help = Image.createImage("/res/btn_main_help.png");
        } catch (IOException io) {
            io.printStackTrace();
            //Dialog.show("Image not Found!", io.getMessage(), "Ok", null);
            System.out.println("Image not found" + io.getMessage());
        }


        //---------   Whole form define as BorderLayout with three Container.
        BorderLayout bor_MainMenuLayout = new BorderLayout();
        setLayout(bor_MainMenuLayout);
        setScrollable(false);

        //----------- Define Container for Header On North
        Container con_Header = new Container();
        lbl_Header = new Label(img_Header);
        con_Header.addComponent(lbl_Header);


        //----------- Define Container as GridLayout and place
        //----------- on BorderLayout Center position
        //---------     Define Container(CENTER) for search details
        //---------     with BoxLayout
        BoxLayout bx_CenterLayout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Center = new Container(bx_CenterLayout);
        con_Center.setScrollableY(true);
        con_Center.getStyle().setPadding(0, 10, 3, 3);

        //---------     FlowLayout for Header Details
        FlowLayout flw_MenuHdr = new FlowLayout();
        Container con_HdrDetails = new Container(flw_MenuHdr);
        lbl_MenuHdr = new Label("Menu");
        lbl_MenuHdr.getStyle().setBgTransparency(0);
        lbl_MenuHdr.getStyle().setPadding(0, 5, 10, 0);

        con_HdrDetails.addComponent(lbl_MenuHdr);

        con_Center.addComponent(con_HdrDetails);

        //----------        GridLayout define 1 rows and 3 coloumn
        //----------        First row
        GridLayout grd_Row1Layout = new GridLayout(1, 3);
        Container con_Row1Layout = new Container(grd_Row1Layout);

        btn_main_Login = new Button(img_main_Login);
        btn_main_Help = new Button(img_main_Help;
        btn_main_NewUser = new Button(img_main_NewUser);

        con_Row1Layout.addComponent(btn_main_Login);
        con_Row1Layout.addComponent(btn_main_Help);
        con_Row1Layout.addComponent(btn_main_NewUser);

        con_Center.addComponent(con_Row1Layout);



        //-----------   Add Command on softkey 
        cmd_Exit = new Command("Exit");
        cmd_Select = new Command("Select");

        addCommand(cmd_Select);
        addCommand(cmd_Exit);
        addCommandListener(this);

        addComponent(BorderLayout.NORTH, con_Header);
        addComponent(BorderLayout.CENTER, con_Center);

        //this.getStyle().setBgColor(12105912);
        frm_Main.getStyle().setBgColor(12105912);

    }

    public void actionPerformed(ActionEvent ae) {
        Command cmd = ae.getCommand();
        String str_CmdName = cmd.getCommandName();

        //-----------       When Click on Exit Button
        if (str_CmdName.equals("Exit")) {
            //System.exit(0);
            //frm_Main.notifyAll();
        }

        //-----------       When Click on Select Button
        if (str_CmdName.equals("Select")) {
            //-----------       When Click on Login
            if (btn_main_Login.hasFocus()) {
                String str_MemberId = GlobalClass.getInstance().getMemberId();

                if (!(str_MemberId == "" || str_MemberId == null)) {
                    SearchDiamond searchdiamond = new SearchDiamond(frm_Main);
                    searchdiamond.setTransitionInAnimator(
                            Transition3D.createRotation(800, true));
                    searchdiamond.show();
                } else {
                    Login login = new Login(frm_Main);
                    login.setTransitionInAnimator(
                            Transition3D.createRotation(800, true));
                    login.show();
                }

            }

            //-----------       When Click on New User
            if (btn_main_NewUser.hasFocus()) {
                //Dialog.show("New User", "NewUser", "Ok", null);
                NewUser newuser = new NewUser(frm_Main);
                //newuser.setTransitionInAnimator(
                        CommonTransitions.createFade(1500));
                newuser.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
                newuser.show();

            }

            //-----------       When Click on Help
            if (btn_main_Help.hasFocus()) {
                Help help = new Help(frm_Main);
                help.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
                help.show();
            }

            //-----------       When Click on Exit
            if (btn_main_Exit.hasFocus()) {
                System.exit(0);
            }

        }
    }
}
class Login extends Form implements ActionListener {

    Form frm_Main;
    Label lbl_Header, lbl_Footer, lbl_SepLine, lbl_HdrAlreadyMember, lbl_UserID, lbl_PWD,
            lbl_Blank2, lbl_Blank3, lbl_HdrNewMember, lbl_Info;
    TextField txtf_UserID, txtf_PWD;
    Button btn_Login;
    Command cmd_Back, cmd_AboutUs, cmd_Privacy;

    public Login(Form form) {
        this.frm_Main = form;

        //---------   Whole form define as BorderLayout with three Container.
        BorderLayout bor_LoginLayout = new BorderLayout();
        setLayout(bor_LoginLayout);
        setScrollable(false);

        //---------   Define Container(NORTH) for Header.
        Container con_Header = new Container();
        lbl_Header = new Label();
        con_Header.addComponent(lbl_Header);


        //---------     Define Container(CENTER) for search details 
        //---------     with BoxLayout
        BoxLayout bx_CenterLayout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Center = new Container(bx_CenterLayout);
        con_Center.setScrollableY(true);
        con_Center.getStyle().setMargin(5, 5, 0, 0);

        //---------     FlowLayout for Header Details
        FlowLayout flw_HdrLayout = new FlowLayout();
        Container con_HdrDetails = new Container(flw_HdrLayout);

        lbl_HdrAlreadyMember = new Label("Already a Member?");
        lbl_HdrAlreadyMember.setAlignment(Component.LEFT);
        con_HdrDetails.addComponent(lbl_HdrAlreadyMember);

        con_Center.addComponent(con_HdrDetails);

        //---------     BoxLayout for Login details
        BoxLayout bx_Login1Layout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Login1Details = new Container(bx_Login1Layout);
        con_Login1Details.setScrollableY(true);


        lbl_UserID = new Label("User Name:");


            txtf_UserID = new TextField("");
        txtf_UserID.setFocusable(true);
        txtf_UserID.setFocus(true);
        txtf_UserID.setConstraint(TextField.ANY);
        txtf_UserID.setInputMode("abc");

        lbl_PWD = new Label("Password:");

        txtf_PWD = new TextField("");
        txtf_PWD.setConstraint(TextField.PASSWORD);


        con_Login1Details.addComponent(lbl_UserID);
        con_Login1Details.addComponent(txtf_UserID);
        con_Login1Details.addComponent(lbl_PWD);
        con_Login1Details.addComponent(txtf_PWD);

        //---------     BoxLayout for Login Button
        FlowLayout flw_LoginBtnLayout = new FlowLayout(CENTER);
        Container con_LoginBtnDetails = new Container(
                flw_LoginBtnLayout);
        con_LoginBtnDetails.setScrollableY(true);

        btn_Login = new Button("Login");
        btn_Login.setPreferredSize(new Dimension(80, 25));
        btn_Login.setAlignment(Component.CENTER);

        con_LoginBtnDetails.addComponent(btn_Login);

        con_Login1Details.addComponent(con_LoginBtnDetails);

        con_Center.addComponent(con_Login1Details);

        //---------     BoxLayout for other Login details
        BoxLayout bx_Login2Layout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Login2Details = new Container(bx_Login2Layout);
        con_Login2Details.setScrollableY(true);
        con_Login2Details.getStyle().setMargin(5, 5, 10, 10);

        //---------     Login type 3 New Remember Me
        chk_RememberMe = new CheckBox("Remember Me");
        chk_RememberMe.setTickerEnabled(false);
        con_Login2Details.addComponent(chk_RememberMe);

        //---------     Login type 3 New Forgot Password
        btn_ForgotPWD = new Button("Forgot Password?");
        btn_ForgotPWD.setTickerEnabled(false);
        btn_ForgotPWD.setAlignment(Component.LEFT);
        btn_ForgotPWD.setTextPosition(Component.RIGHT);

        con_Login2Details.addComponent(btn_ForgotPWD);

        con_Center.addComponent(con_Login2Details);
        con_Center.getStyle().setPadding(0, 0, 10, 10);

        addComponent(BorderLayout.NORTH, con_Header);
        addComponent(BorderLayout.CENTER, con_Center);

        cmd_Back = new Command("Back");
        this.setBackCommand(cmd_Back);
        addCommand(cmd_Back);
        addCommandListener(this);


        //----------  Add More Command for Menu item
        cmd_AboutUs = new Command("About Us");
        cmd_Privacy = new Command("Privacy");

        addCommand(cmd_AboutUs);
        addCommand(cmd_Privacy);

        //-------       When Login Button is Clicked
        btn_Login.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                     ....
            }
        });
    }
    public void actionPerformed(ActionEvent ae) {
        Command con = ae.getCommand();
        String str_CmdName = con.getCommandName();
        if (str_CmdName.equals("Back")) {
            // here back code 
            frm_Main.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
            frm_Main.showBack();
        }

        ....
        if (str_CmdName.equals("About Us")) {
            AboutUs aboutus = new AboutUs(frm_Main);
            aboutus.show();
        }

        if (str_CmdName.equals("Privacy")) {
            Privacy privacy = new Privacy(frm_Main);
            privacy.show();
        }

    }
}
Login.java

public class Splash extends MIDlet implements ActionListener {
    Image img_Splash;
    Form frm_Main;
    String str_URL;
    int Width, Height;
    Label lbl_Splash;
    Command cmd_Cancel;

    public void startApp() {
        Display.init(this);

        frm_Main = new Form();
        try {
            //Resources theme = Resources.open("/44444.res");
            img_Splash = Image.createImage("/res/splash.png");
            Resources theme = Resources.open("/666666.res");
            UIManager.getInstance().setThemeProps(
                    theme.getTheme(theme.getThemeResourceNames()[0]));
        } catch (IOException io) {
            io.printStackTrace();
            Dialog.show("Theme Exception", io.getMessage(), "Ok", null);
        }


        lbl_Splash = new Label(img_Splash);
        lbl_Splash.getStyle().setBgColor(16777215);

        frm_Main.addComponent(lbl_Splash);
        frm_Main.setScrollable(true);

        cmd_Cancel = new Command("Cancel");
        frm_Main.addCommand(cmd_Cancel);
        frm_Main.addCommandListener(this);

        frm_Main.show();

        // th
        Thread splashThread = new Thread() {

            public void run() {
                try {
                    sleep(5000);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();

                } finally {
                    MainMenu mainmenu = new MainMenu(frm_Main);
                    mainmenu.show();
                }
            }
        };
        splashThread.start();
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        //notifyDestroyed();
    }

    public void actionPerformed(ActionEvent ae) {
        Command con = ae.getCommand();
        String str_CmdName = con.getCommandName();

        if (str_CmdName.equals("Cancel")) {
            notifyDestroyed();
        }
    }
}
class MainMenu extends Form implements ActionListener {

    Form frm_Main;
    //MainMidlet main;
    public Button btn_main_Login, btn_main_NewUser, btn_main_Help;
    public Label lbl_main_Login, lbl_main_NewUser, lbl_main_Help;

    public Image img_main_Login, img_main_NewUser, img_main_Help;
    public Command cmd_Exit, cmd_Select;

    public MainMenu(Form form) {
        this.frm_Main = form;
        try {
            img_main_Login = Image.createImage("/res/btn_main_login.png");
            img_main_NewUser = Image.createImage("/res/btn_main_newuser.png");
            img_main_Help = Image.createImage("/res/btn_main_help.png");
        } catch (IOException io) {
            io.printStackTrace();
            //Dialog.show("Image not Found!", io.getMessage(), "Ok", null);
            System.out.println("Image not found" + io.getMessage());
        }


        //---------   Whole form define as BorderLayout with three Container.
        BorderLayout bor_MainMenuLayout = new BorderLayout();
        setLayout(bor_MainMenuLayout);
        setScrollable(false);

        //----------- Define Container for Header On North
        Container con_Header = new Container();
        lbl_Header = new Label(img_Header);
        con_Header.addComponent(lbl_Header);


        //----------- Define Container as GridLayout and place
        //----------- on BorderLayout Center position
        //---------     Define Container(CENTER) for search details
        //---------     with BoxLayout
        BoxLayout bx_CenterLayout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Center = new Container(bx_CenterLayout);
        con_Center.setScrollableY(true);
        con_Center.getStyle().setPadding(0, 10, 3, 3);

        //---------     FlowLayout for Header Details
        FlowLayout flw_MenuHdr = new FlowLayout();
        Container con_HdrDetails = new Container(flw_MenuHdr);
        lbl_MenuHdr = new Label("Menu");
        lbl_MenuHdr.getStyle().setBgTransparency(0);
        lbl_MenuHdr.getStyle().setPadding(0, 5, 10, 0);

        con_HdrDetails.addComponent(lbl_MenuHdr);

        con_Center.addComponent(con_HdrDetails);

        //----------        GridLayout define 1 rows and 3 coloumn
        //----------        First row
        GridLayout grd_Row1Layout = new GridLayout(1, 3);
        Container con_Row1Layout = new Container(grd_Row1Layout);

        btn_main_Login = new Button(img_main_Login);
        btn_main_Help = new Button(img_main_Help;
        btn_main_NewUser = new Button(img_main_NewUser);

        con_Row1Layout.addComponent(btn_main_Login);
        con_Row1Layout.addComponent(btn_main_Help);
        con_Row1Layout.addComponent(btn_main_NewUser);

        con_Center.addComponent(con_Row1Layout);



        //-----------   Add Command on softkey 
        cmd_Exit = new Command("Exit");
        cmd_Select = new Command("Select");

        addCommand(cmd_Select);
        addCommand(cmd_Exit);
        addCommandListener(this);

        addComponent(BorderLayout.NORTH, con_Header);
        addComponent(BorderLayout.CENTER, con_Center);

        //this.getStyle().setBgColor(12105912);
        frm_Main.getStyle().setBgColor(12105912);

    }

    public void actionPerformed(ActionEvent ae) {
        Command cmd = ae.getCommand();
        String str_CmdName = cmd.getCommandName();

        //-----------       When Click on Exit Button
        if (str_CmdName.equals("Exit")) {
            //System.exit(0);
            //frm_Main.notifyAll();
        }

        //-----------       When Click on Select Button
        if (str_CmdName.equals("Select")) {
            //-----------       When Click on Login
            if (btn_main_Login.hasFocus()) {
                String str_MemberId = GlobalClass.getInstance().getMemberId();

                if (!(str_MemberId == "" || str_MemberId == null)) {
                    SearchDiamond searchdiamond = new SearchDiamond(frm_Main);
                    searchdiamond.setTransitionInAnimator(
                            Transition3D.createRotation(800, true));
                    searchdiamond.show();
                } else {
                    Login login = new Login(frm_Main);
                    login.setTransitionInAnimator(
                            Transition3D.createRotation(800, true));
                    login.show();
                }

            }

            //-----------       When Click on New User
            if (btn_main_NewUser.hasFocus()) {
                //Dialog.show("New User", "NewUser", "Ok", null);
                NewUser newuser = new NewUser(frm_Main);
                //newuser.setTransitionInAnimator(
                        CommonTransitions.createFade(1500));
                newuser.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
                newuser.show();

            }

            //-----------       When Click on Help
            if (btn_main_Help.hasFocus()) {
                Help help = new Help(frm_Main);
                help.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
                help.show();
            }

            //-----------       When Click on Exit
            if (btn_main_Exit.hasFocus()) {
                System.exit(0);
            }

        }
    }
}
class Login extends Form implements ActionListener {

    Form frm_Main;
    Label lbl_Header, lbl_Footer, lbl_SepLine, lbl_HdrAlreadyMember, lbl_UserID, lbl_PWD,
            lbl_Blank2, lbl_Blank3, lbl_HdrNewMember, lbl_Info;
    TextField txtf_UserID, txtf_PWD;
    Button btn_Login;
    Command cmd_Back, cmd_AboutUs, cmd_Privacy;

    public Login(Form form) {
        this.frm_Main = form;

        //---------   Whole form define as BorderLayout with three Container.
        BorderLayout bor_LoginLayout = new BorderLayout();
        setLayout(bor_LoginLayout);
        setScrollable(false);

        //---------   Define Container(NORTH) for Header.
        Container con_Header = new Container();
        lbl_Header = new Label();
        con_Header.addComponent(lbl_Header);


        //---------     Define Container(CENTER) for search details 
        //---------     with BoxLayout
        BoxLayout bx_CenterLayout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Center = new Container(bx_CenterLayout);
        con_Center.setScrollableY(true);
        con_Center.getStyle().setMargin(5, 5, 0, 0);

        //---------     FlowLayout for Header Details
        FlowLayout flw_HdrLayout = new FlowLayout();
        Container con_HdrDetails = new Container(flw_HdrLayout);

        lbl_HdrAlreadyMember = new Label("Already a Member?");
        lbl_HdrAlreadyMember.setAlignment(Component.LEFT);
        con_HdrDetails.addComponent(lbl_HdrAlreadyMember);

        con_Center.addComponent(con_HdrDetails);

        //---------     BoxLayout for Login details
        BoxLayout bx_Login1Layout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Login1Details = new Container(bx_Login1Layout);
        con_Login1Details.setScrollableY(true);


        lbl_UserID = new Label("User Name:");


            txtf_UserID = new TextField("");
        txtf_UserID.setFocusable(true);
        txtf_UserID.setFocus(true);
        txtf_UserID.setConstraint(TextField.ANY);
        txtf_UserID.setInputMode("abc");

        lbl_PWD = new Label("Password:");

        txtf_PWD = new TextField("");
        txtf_PWD.setConstraint(TextField.PASSWORD);


        con_Login1Details.addComponent(lbl_UserID);
        con_Login1Details.addComponent(txtf_UserID);
        con_Login1Details.addComponent(lbl_PWD);
        con_Login1Details.addComponent(txtf_PWD);

        //---------     BoxLayout for Login Button
        FlowLayout flw_LoginBtnLayout = new FlowLayout(CENTER);
        Container con_LoginBtnDetails = new Container(
                flw_LoginBtnLayout);
        con_LoginBtnDetails.setScrollableY(true);

        btn_Login = new Button("Login");
        btn_Login.setPreferredSize(new Dimension(80, 25));
        btn_Login.setAlignment(Component.CENTER);

        con_LoginBtnDetails.addComponent(btn_Login);

        con_Login1Details.addComponent(con_LoginBtnDetails);

        con_Center.addComponent(con_Login1Details);

        //---------     BoxLayout for other Login details
        BoxLayout bx_Login2Layout = new BoxLayout(BoxLayout.Y_AXIS);
        Container con_Login2Details = new Container(bx_Login2Layout);
        con_Login2Details.setScrollableY(true);
        con_Login2Details.getStyle().setMargin(5, 5, 10, 10);

        //---------     Login type 3 New Remember Me
        chk_RememberMe = new CheckBox("Remember Me");
        chk_RememberMe.setTickerEnabled(false);
        con_Login2Details.addComponent(chk_RememberMe);

        //---------     Login type 3 New Forgot Password
        btn_ForgotPWD = new Button("Forgot Password?");
        btn_ForgotPWD.setTickerEnabled(false);
        btn_ForgotPWD.setAlignment(Component.LEFT);
        btn_ForgotPWD.setTextPosition(Component.RIGHT);

        con_Login2Details.addComponent(btn_ForgotPWD);

        con_Center.addComponent(con_Login2Details);
        con_Center.getStyle().setPadding(0, 0, 10, 10);

        addComponent(BorderLayout.NORTH, con_Header);
        addComponent(BorderLayout.CENTER, con_Center);

        cmd_Back = new Command("Back");
        this.setBackCommand(cmd_Back);
        addCommand(cmd_Back);
        addCommandListener(this);


        //----------  Add More Command for Menu item
        cmd_AboutUs = new Command("About Us");
        cmd_Privacy = new Command("Privacy");

        addCommand(cmd_AboutUs);
        addCommand(cmd_Privacy);

        //-------       When Login Button is Clicked
        btn_Login.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                     ....
            }
        });
    }
    public void actionPerformed(ActionEvent ae) {
        Command con = ae.getCommand();
        String str_CmdName = con.getCommandName();
        if (str_CmdName.equals("Back")) {
            // here back code 
            frm_Main.setTransitionInAnimator(
                        Transition3D.createRotation(800, true));
            frm_Main.showBack();
        }

        ....
        if (str_CmdName.equals("About Us")) {
            AboutUs aboutus = new AboutUs(frm_Main);
            aboutus.show();
        }

        if (str_CmdName.equals("Privacy")) {
            Privacy privacy = new Privacy(frm_Main);
            privacy.show();
        }

    }
}
编辑:添加了表单的源代码

明白了

Main菜单(…)
构造函数中,您将
SPLASH
屏幕的引用存储在类变量
frm\u Main
中,该类变量将传递给
Main菜单中的
登录(…)
构造函数。操作执行(…)
非常有效地传递了SPLASH表单对象的引用。您需要将当前类(即
Main菜单的
引用)传递给
Login(…)
构造函数,而不是
Main菜单.frm\u Main

如果您不希望从
main菜单返回
Splash
屏幕,请执行此操作:

public MainMenu(Form form)
{
    this.frm_Main = this;  //by referring to `MainMenu.this` and not input 
                           //parameter `form` which is referring to Splash
                           //object

    ...
如果要维护MainMenu屏幕的back reference,请在
MainMenu.actionPerformed(…)


有很多未知因素和场景会导致此问题?请提供您的代码片段以获得更多帮助?感谢重播,我在这里添加了一些代码!请帮助我编辑。这里有问题解决说明。非常欢迎,如果您能够解决问题,请标记答案,并帮助本帖的未来读者。@HarshadaDhamapurkar如果您认为这有助于解决问题,请标记并接受此答案。