Search code examples
textboxjava-melcdui

J2ME TextBox not editable


Is there any way to get a TextBox in j2me not editable?

Because I want to fill a lot of lines but I don't want the user to edit it.


Solution

  • For Textbox, this can be achieved by setting TextField.UNEDITABLE constraint (TextField is not a typo):

    Indicates that editing is currently disallowed. When this flag is set, the implementation must prevent the user from changing the text contents of this object. The implementation should also provide a visual indication that the object's text cannot be edited. The intent of this flag is that this text object has the potential to be edited, and that there are circumstances where the application will clear this flag and allow the user to edit the contents.

    The UNEDITABLE modifier can be combined with other input constraints by using the bit-wise OR operator (|).

    UNEDITABLE modifier can be set in TextBox constructor, as well as using setConstraints method. If you're interested in more details on that, refer to TextBox API javadocs