Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home J2me J2ME Text Box Example

Related Tutorials


 
 

Share on Google+Share on Google+

J2ME Text Box Example

Advertisement
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

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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: December 2, 2008

Related Tutorials

Discuss: J2ME Text Box Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
pacifique bayongwa
December 28, 2011
autocomplete textbox in j2me

hi, Am working on a J2me project trying to make a bilingual dictionary.my proble is i cant create a autocomplete textbox or autocomplete editable combobox, such a way if a user is entering a word the word autocomplte progressively. please help
DMCA.com