Show difference component after showBack()

40 views
Skip to first unread message

Hùng Phạm

unread,
Sep 3, 2014, 6:08:07 AM9/3/14
to codenameone...@googlegroups.com
Dear Cn1
My app is using a little code similar with your Facebook Demo with Sidemenu bar. When user log in, it show a blank component. And i want to show another component if user log in successful.
Is there anyway to handle event from main form when i call showBack() from login form?

mainForm.java

 public void start() {
        System.out.println("started");
        if (main != null) {
            main.show();
            return;
        }
         ...
        main = new Form("");
        main.setLayout(new BorderLayout());
        main.addComponent(BorderLayout.CENTER, showMain());
         ...
        main.show();
        if (!login){
            showLoginDiaLog();
        }
LoginForm.java
        if (ilogin.checkLogin(domain, username, password)) {
                            ilogin.setSignIn(true);
                            form.showBack();
                        } 

Shai Almog

unread,
Sep 3, 2014, 12:23:12 PM9/3/14
to codenameone...@googlegroups.com
Hi,
assuming you have the event that the other form was shown just set a boolean flag in the state machine to true.

Then in your before show method check the flag, if its set to true just add your components to the form.

Hùng Phạm

unread,
Sep 3, 2014, 10:55:02 PM9/3/14
to codenameone...@googlegroups.com
I use manual code so i dont want to use UIBuilder and MachineState. By the way, i found the solution. thank for your suggestion. 


Reply all
Reply to author
Forward
0 new messages