Home J2me J2ME Text Box Example



J2ME Text Box Example
Posted on: December 2, 2008 at 12:00 AM
This application illustrates how to create the text box using TextBox class.

J2ME Text Box Example

     

This application illustrates how to create the text box using TextBox class. The TextBox class is a Screen that allows the user to enter and edit text. A TextBox has a maximum size, which is the maximum number of characters that can be stored in the object at any time. The following are the methods used in class:

  • delete(int offset, int length)
  • getCaretPosition()
  • getChars(char[] data)
  • getConstraints()
  • getMaxSize()
  • getString()
  • insert(char[] data, int offset, int length, int position)
  • insert(String src, int position)
  • setChars(char[] data, int offset, int length)
  • setConstraints(int constraints)
  • setMaxSize(int maxSize)
  • setString(String text)
  • size()

These methods are accessible in your MIDlet. The application is as follows:

 

TextBoxMIDlet.java

 

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

public class TextBoxMIDlet extends MIDlet{
  
  private Display display; 

  public TextBoxMIDlet() {
  display = Display.getDisplay(this);
  }

  public void startApp() {
  TextBox t = new TextBox("TextBox Example"

   "Hello Sandeep Kumar Suman !"2560);
  display.setCurrent(t);
  }

  public void pauseApp() {}

  public void destroyApp(boolean unconditional) {}
}

 

Download Source Code

Related Tags for J2ME Text Box Example:
cclasstextapplicationtextboxiousingthisappcreatetexboxtoexteilliinastrcacleshowpprateratescatsatislleastrxtsstbothstatiapicaicaplono


More Tutorials from this section

Ask Questions?    Discuss: J2ME Text Box Example   View All Comments

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.