×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    153

    how we can go back form to midlet class form

    I am working on S40 using sdk2.0 and lwuit 1.5.my requirment is that i am using class which extends Midlet class.I am using a form in this class .now i am also using a another class which extends Form class.when i click on button form midlet class second class form is open now i want to go back on midlet class form.so how it is possible .we can't instantiate any object which class extends midlet so please it is a very big isssue for me .help me

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    603

    Re: how we can go back form to midlet class form

    Sorry but you are not clear with what you are trying to do, try and rephrase your question and maybe also provide code samples of what you have.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,569

    Re: how we can go back form to midlet class form

    You need the Form variable from the single, already existing Midlet, not a new Midlet.

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: how we can go back form to midlet class form

    Basically you want to switch forms from a midlet.

    so its like

    Code:
    MyMidlet extends Midlet {
    
    public void showFormOne() {
    formOne.show();
    }
    public void showFormTwo()
    formTwo.show();
    }
    now pass this midlet object in your forms and call showFormOne from form2 and if you want to get back to form1 call show Form2.

  5. #5
    Registered User
    Join Date
    May 2013
    Posts
    12

    Re: how we can go back form to midlet class form

    Hi,
    You can create classes for each of the screens of your application and manage them from the main midlet.

    A form is an object of the class can create the form and content from the builder and display using the method show ().

    Remember you're still using OOP

  6. #6
    Registered User
    Join Date
    May 2013
    Posts
    153

    Re: how we can go back form to midlet class form

    In my project in default package there is a class which extends MIDlet classs and another class in same package which extends Form class.when i run project form is show which is in midlet class and I press the button of first form then control open second form which is in second class which extends Form. Then i want to go back on first form so how is it possible.

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: how we can go back form to midlet class form

    As mentioned in last two post please try that. You just need to define two methods in your midlet and can navigate to each other !!

  8. #8
    Registered User
    Join Date
    May 2013
    Posts
    153

    Re: how we can go back form to midlet class form

    my code is
    Code:
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    
    
    
    public class Listrendered extends MIDlet {
    	
    	Form f;
    	public Listrendered() {
    		// TODO Auto-generated constructor stub
    	}
    
    	protected void destroyApp(boolean arg0){
    		// TODO Auto-generated method stub
    
    	}
    
    	protected void pauseApp() {
    		// TODO Auto-generated method stub
    
    	}
    
    	protected void startApp()  {
    		// TODO Auto-generated method stub
    		Display.init(this);
    		Display.getInstance().setForceFullScreen(true);
    		 f=new Form();
    		 f.setLayout(new BorderLayout());
    		Button b=new Button();
    		b.addActionListener(new ActionListener() {
    			
    			public void actionPerformed(ActionEvent arg0) {
    				// TODO Auto-generated method stub
    			       Secondclass cs=new Secondclass();
                                   cs.showform();
    			}
    		});
    		
    		
    		f.addComponent(BorderLayout.CENTER,l);
    		f.addComponent(BorderLayout.NORTH,b);
    		f.show();
    		
    		
    	}
    Now my second class is
    Code:
    public class Secondclass
    {
    public void showform()
    {
    Form f=new Form();
    Button b=new Button();
    b.addActionListener(new ActionListener() {
    			
    public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub
    
    }
    });
    		
    
    
    }
    
    }
    NOW i want to go back first form on click on button so tell me how i can go back back on form
    so please help me
    Last edited by wizard_hu_; 2013-08-03 at 11:02. Reason: a [/CODE] added

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,569

    Re: how we can go back form to midlet class form

    As it was mentioned already, you need to access the Midlet's "Form f". It can be done in multiple ways, the simplest one would be simply providing its reference explicitly to SecondClass objects:
    - create a member variable and a constructor
    Code:
    public class SecondClass
    {
        final Form midletForm;
        public SecondClass(Form f)
        {
            midletForm=f;
        }
    - use it in the Midlet code, startApp
    Code:
    ...
    Secondclass cs=new Secondclass(f);
    cs.showform();
    ...
    - and in SecondClass use the Form when necessary
    Code:
    public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub
    midletForm.show();
    }
    Last edited by wizard_hu_; 2013-08-03 at 11:18.

  10. #10
    Registered User
    Join Date
    May 2013
    Posts
    153

    Re: how we can go back form to midlet class form

    thanks wizard_hu_. I applied as you told me my code is [CODE]protected void startApp() {
    // TODO Auto-generated method stub
    Display.init(this);
    //Display.getInstance().setForceFullScreen(true);
    f=new Form();
    // f.setLayout(new BorderLayout());
    Button b=new Button();
    b.addActionListener(new ActionListener() {

    public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub
    SecondForm sc=new SecondForm(f);
    sc.showform();
    }
    });

    f.addComponent(b);
    f.show();


    }
    [/COCE]
    and second class is
    Code:
    public class SecondForm {
    	public  Form form;
    	public SecondForm(Form f) {
    		// TODO Auto-generated constructor stub
    		form=f;
    	}
    	
    	public void showform()
    	{
    	 form=new Form();
    	Button b=new Button("helo");
    	b.addActionListener(new ActionListener() {
    		
    		public void actionPerformed(ActionEvent arg0) {
    			// TODO Auto-generated method stub
    			System.out.println("second form");
    			form.show();
    		}
    	});
    	form.addComponent(b);
    	form.show();
    	}
    }
    BUT till now i am not able to go back to midlet form on button click.

  11. #11
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,569

    Re: how we can go back form to midlet class form

    No, this is not what I suggested. You are overwriting the variable 'form' in SecondClass.

  12. #12
    Registered User
    Join Date
    May 2013
    Posts
    153

    Re: how we can go back form to midlet class form

    thax a lot .now it is completed thanks
    Last edited by vikranttanwar@; 2013-08-03 at 13:24.

Similar Threads

  1. Getting back to the same form
    By faysal515 in forum Mobile Java General
    Replies: 5
    Last Post: 2013-05-03, 21:01
  2. How to set Form to Back in LWUIT??
    By rajan701v in forum Mobile Java General
    Replies: 6
    Last Post: 2011-02-17, 11:00
  3. problem in back and forth of LWUIT form and normal form in j2me
    By jugal.inani in forum Mobile Java General
    Replies: 8
    Last Post: 2010-06-09, 12:24
  4. newbie question: how to exit midlet form canvas class
    By mahmoudawad2004 in forum Mobile Java General
    Replies: 7
    Last Post: 2007-04-04, 02:06
  5. MIDlet! mapping Command to a class extends Form
    By enpar in forum Mobile Java General
    Replies: 0
    Last Post: 2003-02-07, 13:18

Posting Permissions

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