×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    93

    Thumbs up How to call a form from another class

    I am using Lwuit 1.3 and Netbeans for my Application.

    I have two classes.
    In first class, i show a form(screen),
    In second class, i show another form.

    From second class, if i click on Back command,it will show First form(previous form present in first class). How to do this.Plz Help me....

    Example Coding:

    class c1
    {
    Form f1=new Form("First Form");
    f1.show();
    }

    class c2
    {
    Form f2=new Form("Second Form");
    f2.addCommand(new Command(){public void actionPerformed(){
    f1.show();//Is it Correct
    }});
    f2.show();
    }

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to call a form from another class

    Quote Originally Posted by ramtrg View Post
    I am using Lwuit 1.3 and Netbeans for my Application.

    I have two classes.
    In first class, i show a form(screen),
    In second class, i show another form.

    From second class, if i click on Back command,it will show First form(previous form present in first class). How to do this.Plz Help me....

    Example Coding:

    class c1
    {
    Form f1=new Form("First Form");
    f1.show();
    }

    class c2
    {
    Form f2=new Form("Second Form");
    f2.addCommand(new Command(){public void actionPerformed(){
    f1.show();//Is it Correct
    }});
    f2.show();
    }
    Nope that is not correct.

    You have to override the actionperformed() method in your form, and inside that you need to check that whether the command was back, if yes then using the MIDlet, display object and set the previous form as the current displayable.

    PHP Code:
        public void actionPerformed(ActionEvent event) {
     
    // You can check here that event.getCommand().getId() is equal to the back command id,then change the displayable.
        

        

    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    93

    Re: How to call a form from another class

    hello Raj sir...Could you explain little bit more about my issue....if possible give me example coding...I am eagerly waiting for your reply...

  4. #4
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: How to call a form from another class

    2nd class to implement CommandListener

    class c2 extends MIDlet implements CommandListener {
    ..........
    ..........
    public void actionPerformed (c,d) { // declare properly

    if (c == backCmd) {
    display.setCurrent (form1);
    }

    }
    }

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to call a form from another class

    Quote Originally Posted by nathviswa View Post
    2nd class to implement CommandListener

    class c2 extends MIDlet implements CommandListener {
    ..........
    ..........
    public void actionPerformed (c,d) { // declare properly

    if (c == backCmd) {
    display.setCurrent (form1);
    }

    }
    }
    Dear he is asking this for the LWUIT and not for the Form, high lavel API.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to call a form from another class

    Quote Originally Posted by ramtrg View Post
    hello Raj sir...Could you explain little bit more about my issue....if possible give me example coding...I am eagerly waiting for your reply...
    Could you check this Here, very nicely explained all the basics of the LWUIT.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  7. #7
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    93

    Re: How to call a form from another class

    Quote Originally Posted by raj_J2ME View Post
    Could you check this Here, very nicely explained all the basics of the LWUIT.
    Thank you Raj sir, I go through above link, but in that link,Forms showed in same class only...My problem is Forms in two different classes. I have initialized and show a form in first class, and then again i want to show that form in second class(If i click Back Command in second form,it should show first form). How to access first class form in second class.
    Last edited by ramtrg; 2011-01-10 at 02:21.

Similar Threads

  1. Replies: 1
    Last Post: 2010-09-29, 09:25
  2. Call another class from a Midlet Class
    By iamvinay in forum Mobile Java General
    Replies: 1
    Last Post: 2010-07-16, 15:47
  3. How to call the other form from the present form
    By Tejaswini in forum Symbian User Interface
    Replies: 1
    Last Post: 2007-07-24, 08:42
  4. c Class derive only form Cbase
    By karanala in forum Symbian
    Replies: 3
    Last Post: 2007-02-23, 08:39
  5. Form Class on Series 60
    By richard clark in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-07-12, 16:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×