Search code examples
java-meconstraintstextfieldmidplcdui

j2me set textfield constraints


I have to textfield in midlet. One for entering the date in format (DD.MM.YYYY), second for enternig only one letter. Is it possible to set such constraints that the first textfield accepts only numbers and dots and the second only one symbol?


Solution

  • To make it accept only one symbol is very easy with TextField API - just properly use maxSize parameter in constructor or setMaxSize method.

    It is not possible to set such constraints that a textfield accepts only numbers and dots.

    • To get an input like you describe, I would probably just use three NUMERIC text fields instead - for user to enter DD, MM and YYYY digits respectively