📄 textfield.html
字号:
are obscured is implementation-dependent. For example, each character of the data might be masked with a "<code>*</code>" character. The <code>PASSWORD</code> modifier is useful for entering confidential information such as passwords or personal identification numbers (PINs). <p>Data entered into a <code>PASSWORD</code> field is treated similarly to <code>SENSITIVE</code> in that the implementation must never store the contents into a dictionary or table for use in predictive, auto-completing, or other accelerated input schemes. If the <code>PASSWORD</code> bit is set in a constraint value, the <code>SENSITIVE</code> and <code>NON_PREDICTIVE</code> bits are also considered to be set, regardless of their actual values. In addition, the <code>INITIAL_CAPS_WORD</code> and <code>INITIAL_CAPS_SENTENCE</code> flag bits should be ignored even if they are set.</p> <p>The <code>PASSWORD</code> modifier can be combined with other input constraints by using the bit-wise <code>OR</code> operator (<code>|</code>). The <code>PASSWORD</code> modifier is not useful with some constraint values such as <code>EMAILADDR</code>, <code>PHONENUMBER</code>, and <code>URL</code>. These combinations are legal, however, and no exception is thrown if such a constraint is specified.</p> <p>Constant <code>0x10000</code> is assigned to <code>PASSWORD</code>.</p></DL>
<HR>
<A NAME="UNEDITABLE"><!-- --></A><H3>
UNEDITABLE</H3>
<PRE>
public static final int <B>UNEDITABLE</B></PRE>
<DL>
<DD>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. <p>The <code>UNEDITABLE</code> modifier can be combined with other input constraints by using the bit-wise <code>OR</code> operator (<code>|</code>). <p>Constant <code>0x20000</code> is assigned to <code>UNEDITABLE</code>.<DD><DL>
<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="SENSITIVE"><!-- --></A><H3>
SENSITIVE</H3>
<PRE>
public static final int <B>SENSITIVE</B></PRE>
<DL>
<DD>Indicates that the text entered is sensitive data that the implementation must never store into a dictionary or table for use in predictive, auto-completing, or other accelerated input schemes. A credit card number is an example of sensitive data. <p>The <code>SENSITIVE</code> modifier can be combined with other input constraints by using the bit-wise <code>OR</code> operator (<code>|</code>).</p> <p>Constant <code>0x40000</code> is assigned to <code>SENSITIVE</code>.</p><DD><DL>
<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="NON_PREDICTIVE"><!-- --></A><H3>
NON_PREDICTIVE</H3>
<PRE>
public static final int <B>NON_PREDICTIVE</B></PRE>
<DL>
<DD>Indicates that the text entered does not consist of words that are likely to be found in dictionaries typically used by predictive input schemes. If this bit is clear, the implementation is allowed to (but is not required to) use predictive input facilities. If this bit is set, the implementation should not use any predictive input facilities, but it instead should allow character-by-character text entry. <p>The <code>NON_PREDICTIVE</code> modifier can be combined with other input constraints by using the bit-wise <code>OR</code> operator (<code>|</code>). <P>Constant <code>0x80000</code> is assigned to <code>NON_PREDICTIVE</code>.</P><DD><DL>
<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="INITIAL_CAPS_WORD"><!-- --></A><H3>
INITIAL_CAPS_WORD</H3>
<PRE>
public static final int <B>INITIAL_CAPS_WORD</B></PRE>
<DL>
<DD>This flag is a hint to the implementation that during text editing, the initial letter of each word should be capitalized. This hint should be honored only on devices for which automatic capitalization is appropriate and when the character set of the text being edited has the notion of upper case and lower case letters. The definition of word boundaries is implementation-specific. <p>If the application specifies both the <code>INITIAL_CAPS_WORD</code> and the <code>INITIAL_CAPS_SENTENCE</code> flags, <code>INITIAL_CAPS_WORD</code> behavior should be used. <p>The <code>INITIAL_CAPS_WORD</code> modifier can be combined with other input constraints by using the bit-wise <code>OR</code> operator (<code>|</code>). <p>Constant <code>0x100000</code> is assigned to <code>INITIAL_CAPS_WORD</code>.<DD><DL>
<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="INITIAL_CAPS_SENTENCE"><!-- --></A><H3>
INITIAL_CAPS_SENTENCE</H3>
<PRE>
public static final int <B>INITIAL_CAPS_SENTENCE</B></PRE>
<DL>
<DD>This flag is a hint to the implementation that during text editing, the initial letter of each sentence should be capitalized. This hint should be honored only on devices for which automatic capitalization is appropriate and when the character set of the text being edited has the notion of upper case and lower case letters. The definition of sentence boundaries is implementation-specific. <p>If the application specifies both the <code>INITIAL_CAPS_WORD</code> and the <code>INITIAL_CAPS_SENTENCE</code> flags, <code>INITIAL_CAPS_WORD</code> behavior should be used. <p>The <code>INITIAL_CAPS_SENTENCE</code> modifier can be combined with other input constraints by using the bit-wise <code>OR</code> operator (<code>|</code>). <p>Constant <code>0x200000</code> is assigned to <code>INITIAL_CAPS_SENTENCE</code>.<DD><DL>
<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="CONSTRAINT_MASK"><!-- --></A><H3>
CONSTRAINT_MASK</H3>
<PRE>
public static final int <B>CONSTRAINT_MASK</B></PRE>
<DL>
<DD>The mask value for determining the constraint mode. The application should use the bit-wise <code>AND</code> operation with a value returned by <code>getConstraints()</code> and <code>CONSTRAINT_MASK</code> in order to retrieve the current constraint mode, in order to remove any modifier flags such as the <code>PASSWORD</code> flag. <P>Constant <code>0xFFFF</code> is assigned to <code>CONSTRAINT_MASK</code>.</P></DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="TextField(java.lang.String, java.lang.String, int, int)"><!-- --></A><H3>
TextField</H3>
<PRE>
public <B>TextField</B>(<A HREF="../../../java/lang/String.html">String</A> label, <A HREF="../../../java/lang/String.html">String</A> text, int maxSize, int constraints)</PRE>
<DL>
<DD>Creates a new <code>TextField</code> object with the given label, initial contents, maximum size in characters, and constraints. If the text parameter is <code>null</code>, the <code>TextField</code> is created empty. The <code>maxSize</code> parameter must be greater than zero. An <code>IllegalArgumentException</code> is thrown if the length of the initial contents string exceeds <code>maxSize</code>. However, the implementation may assign a maximum size smaller than the application had requested. If this occurs, and if the length of the contents exceeds the newly assigned maximum size, the contents are truncated from the end in order to fit, and no exception is thrown.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>label</CODE> - item label<DD><CODE>text</CODE> - the initial contents, or <code>null</code> if the <code>TextField</code> is to be empty<DD><CODE>maxSize</CODE> - the maximum capacity in characters<DD><CODE>constraints</CODE> - see <a href="#constraints">input constraints</a><DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>maxSize</code> is zero or less<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the value of the constraints parameter is invalid<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>text</code> is illegal for the specified constraints<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the length of the string exceeds the requested maximum capacity</DL>
</DD>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="getString()"><!-- --></A><H3>
getString</H3>
<PRE>
public <A HREF="../../../java/lang/String.html">String</A> <B>getString</B>()</PRE>
<DL>
<DD>Gets the contents of the <code>TextField</code> as a string value.<DD><DL>
<DT><B>Returns:</B><DD>the current contents<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/TextField.html#setString(java.lang.String)"><CODE>setString(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setString(java.lang.String)"><!-- --></A><H3>
setString</H3>
<PRE>
public void <B>setString</B>(<A HREF="../../../java/lang/String.html">String</A> text)</PRE>
<DL>
<DD>Sets the contents of the <code>TextField</code> as a string value, replacing the previous contents.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the new value of the <code>TextField</code>, or <code>null</code> if the TextField is to be made empty<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>text</code> is illegal for the current <a href="TextField.html#constraints">input constraints</a><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the text would exceed the current maximum capacity<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/TextField.html#getString()"><CODE>getString()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getChars(char[])"><!-- --></A><H3>
getChars</H3>
<PRE>
public int <B>getChars</B>(char[] data)</PRE>
<DL>
<DD>Copies the contents of the <code>TextField</code> into a character array starting at index zero. Array elements beyond the characters copied are left unchanged.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>data</CODE> - the character array to receive the value<DT><B>Returns:</B><DD>the number of characters copied<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if the array is too short for the contents<DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>data</code> is <code>null</code><DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/TextField.html#setChars(char[], int, int)"><CODE>setChars(char[], int, int)</CODE></A></DL>
</DD>
</DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -