Home J2me Appending string in J2ME Form



Appending string in J2ME Form
Posted on: November 20, 2008 at 12:00 AM
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

Related Tags for Appending string in J2ME Form:
cstringormformtimediffioexamplesvidifferenceusingintappendthisappifforexampleaddtolearnexamearboteititemitemspeimceinrmmntouttrosddosadesememsendalmpenmehowintoppsamexaxampsatishaimemplpregoeaarstrsassamssamriringrenteathstabaphatfepleplprmostndonlyononl


More Tutorials from this section

Ask Questions?    Discuss: Appending string in J2ME Form  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.