Search code examples
javajava-memidplcdui

how to create TextFields dynamically in j2me?


we are developing Mobile application in j2me.In my application, we are using TextField and some other controls in Form.Here, my problem is i want to dynamically create TextField based on User's Credentials.For Example, If Manager is entered,then i want to create certain TextField(based on Manager Selection) for getting input from the Manager.Otherwise,i just want to create TextField that are less than the Manager TextField.

How to Create TextFields Dynamically...

For example like this...

int userSelection=10;

for(int i=0;i<userSelection;i++)
    TextField text=new TextField("Some Name",null);

here, our problem is,

I want to create TextField With Different Name...

Please guide me to get out of this issue...


Solution

  • Create the TextField array and refer from array index.

    TextField[] textFields = new TextField[10];
    for (int i = 0; i < textFields.length; i++) {
         textFields[0] = new TextField(label, text, maxSize, constraint);
    }