×

Discussion Board

Results 1 to 3 of 3

Thread: Test field

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    14

    Test field

    Hi all,
    I am Jay, i need help regarding text field.
    i created one text field
    textField = new TextField("Leaf Width", null, 1, TextField.NUMERIC);
    the text field value take 1 numeric input, but i need to restrict the value like if the input is above 4 it should be set to 4
    and if the value less than 1 i need set this to 1 ie min. i cant find code if u any idea please help me i am new to j2me
    .
    Thanks and Kind regards
    Jay

  2. #2
    Nokia Developer Champion
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Test field

    have you read the javadoc regarding the TextField class ?
    Cause there are methods to read the value inserted by the user, so first you read it, then you compare it to see if it's inbetween 1 and 4 (if you don't know how to do this stop trying to write a j2me app and start by learning basic java) and then if needed you can replace the value which has been inserted with your maximum or minimum value...
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  3. #3
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Test field

    Quote Originally Posted by mrjayaram View Post
    Hi all,
    I am Jay, i need help regarding text field.
    i created one text field
    textField = new TextField("Leaf Width", null, 1, TextField.NUMERIC);
    the text field value take 1 numeric input, but i need to restrict the value like if the input is above 4 it should be set to 4
    and if the value less than 1 i need set this to 1 ie min. i cant find code if u any idea please help me i am new to j2me

    Thanks and Kind regards
    Jay
    You need to add ItemStateListener to your text field, when user enters any value itemStateChanged(item) method will be called, you can put a check here in your implementation of this method, getString from TextField Paseitin INT and check the values and set it back based on your rules.

    itemStateChanged


    public void itemStateChanged(Item item)
    Called when internal state of an Item has been changed by the user. This happens when the user:
    changes the set of selected values in a ChoiceGroup;
    adjusts the value of an interactive Gauge;
    enters or modifies the value in a TextField;
    enters a new date or time in a DateField; and
    Item.notifyStateChanged() was called on an Item.
    It is up to the device to decide when it considers a new value to have been entered into an Item. For example, implementations of text editing within a TextField vary greatly from device to device.

    In general, it is not expected that the listener will be called after every change is made. However, if an item's value has been changed, the listener will be called to notify the application of the change before it is called for a change on another item, and before a command is delivered to the Form's CommandListener. For implementations that have the concept of an input focus, the listener should be called no later than when the focus moves away from an item whose state has been changed. The listener should be called only if the item's value has actually been changed.

    The listener is not called if the application changes the value of an interactive item.

    Parameters:
    item - the item that was changed
    Thanks,
    Ekta

Similar Threads

  1. ftdaserver.exe (Field Test)
    By viewsonic0123 in forum Symbian Networking & Messaging (Closed)
    Replies: 9
    Last Post: 2011-03-30, 01:55
  2. How to Build a field test sw like "field test"?
    By felong in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-04-24, 07:45
  3. RF Measurements, Tracer, Field Test Phone, Test Mobile Firmware
    By gerberm in forum General Development Questions
    Replies: 0
    Last Post: 2005-09-26, 11:54
  4. Description for Field Test programme for 6630?
    By ds77 in forum General Development Questions
    Replies: 2
    Last Post: 2005-02-02, 10:52
  5. Nokia 6310i Field Test Display bug
    By Nikitin.A in forum General Development Questions
    Replies: 0
    Last Post: 2003-06-11, 10:14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •