Home J2me Appending string in J2ME Form
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Appending string in J2ME Form

Advertisement
In the previous example, you learned about how to add items in to the form. In this example we are going to add string into the form.

Appending string in J2ME Form

     

In the previous example, you learned about how to add items in to the form. In this example we are going to add string into the form. Both examples are almost same but the only difference is that this time we are using append string instead of append item.

Syntax for appending string into the form..

public int append(String str)

 

 

 

The Midlet will look like as follow..

Source Code of AppendString.java

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class AppendString extends MIDlet{
  private Display display;
  private AppendFormClass form;
  private MIDlet midlet;
  
  protected void startApp(){
  form = new AppendFormClass("Form Created"this);
  display = Display.getDisplay(this);
  display.setCurrent(form);
  }

  protected void pauseApp(){}

  protected void destroyApp(boolean unconditional){}

  class AppendFormClass extends Form implements CommandListener{
  private Command exit;
  private String string;
  
  public AppendFormClass(String title, MIDlet items){
  super(title);
  midlet = items;
  string = "Sandeep kumar suman";
  exit = new Command("Exit", Command.BACK, 1);
  append(string);
  this.addCommand(this.exit);
  this.setCommandListener(this);
  }

  public void commandAction(Command c, Displayable d){
  String label = c.getLabel();
  if(label.equals("Exit")){
  midlet.notifyDestroyed()
  }
  }
  }
}

 

Download Source Code

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 20, 2008

Ask Questions?    Discuss: Appending string in J2ME Form  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com