I am new to J2ME Programming so i am stuck with the keylisteners..

I am writing a simple J2ME app in which there are 2 textfields. As soon as the user types a char in first textfield the result must be displayed in second.

I want to handle the events of changes in data of TextField. Can any body tell what listener to use for it and how to do it ???

Recommended Answers

All 2 Replies

Only way to do is through setItemCommandListener(). You need implement new Command and then listen when this is triggered and execute whatever logic you need

As peter_budo told, use ItemStateListener(), and implement Abstract Method of it,

public void itemStateChanged(Item item)
{

}

Set this listener to your form. and then write following code :

public void itemStateChanged(Item item)
{
 if( item == txtFld1)
 {
       // Do something when State change of TextField1
 }
  if( item == txtFld2)
 {
       // Do something when State change of TextField2
 }
}

Hope, this will help you. If you have any questions regarding to this then ask.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.