📄 textfield.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Wed Sep 24 14:57:49 PDT 2003 -->
<TITLE>
MID Profile: Class TextField
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/TextField.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<strong>MID Profile</strong></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/microedition/lcdui/TextBox.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/lcdui/Ticker.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="TextField.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.microedition.lcdui</FONT>
<BR>
Class TextField</H2>
<PRE>
<A HREF="../../../java/lang/Object.html">java.lang.Object</A>
|
+--<A HREF="../../../javax/microedition/lcdui/Item.html">javax.microedition.lcdui.Item</A>
|
+--<B>javax.microedition.lcdui.TextField</B>
</PRE>
<HR>
<DL>
<DT>public class <B>TextField</B><DT>extends <A HREF="../../../javax/microedition/lcdui/Item.html">Item</A></DL>
<P>
A <code>TextField</code> is an editable text component that may be placed into a <A HREF="../../../javax/microedition/lcdui/Form.html"><CODE>Form</CODE></A>. It can be given a piece of text that is used as the initial value. <P>A <code>TextField</code> has a maximum size, which is the maximum number of characters that can be stored in the object at any time (its capacity). This limit is enforced when the <code>TextField</code> instance is constructed, when the user is editing text within the <code>TextField</code>, as well as when the application program calls methods on the <code>TextField</code> that modify its contents. The maximum size is the maximum stored capacity and is unrelated to the number of characters that may be displayed at any given time. The number of characters displayed and their arrangement into rows and columns are determined by the device. </p> <p>The implementation may place a boundary on the maximum size, and the maximum size actually assigned may be smaller than the application had requested. The value actually assigned will be reflected in the value returned by <A HREF="../../../javax/microedition/lcdui/TextField.html#getMaxSize()"><CODE>getMaxSize()</CODE></A>. A defensively-written application should compare this value to the maximum size requested and be prepared to handle cases where they differ.</p> <a name="constraints"></a> <h3>Input Constraints</h3> <P>The <code>TextField</code> shares the concept of <em>input constraints</em> with the <A HREF="../../../javax/microedition/lcdui/TextBox.html"><CODE>TextBox</CODE></A> class. The different constraints allow the application to request that the user's input be restricted in a variety of ways. The implementation is required to restrict the user's input as requested by the application. For example, if the application requests the <code>NUMERIC</code> constraint on a <code>TextField</code>, the implementation must allow only numeric characters to be entered. </p> <p>The <em>actual contents</em> of the text object are set and modified by and are reported to the application through the <code>TextBox</code> and <code>TextField</code> APIs. The <em>displayed contents</em> may differ from the actual contents if the implementation has chosen to provide special formatting suitable for the text object's constraint setting. For example, a <code>PHONENUMBER</code> field might be displayed with digit separators and punctuation as appropriate for the phone number conventions in use, grouping the digits into country code, area code, prefix, etc. Any spaces or punctuation provided are not considered part of the text object's actual contents. For example, a text object with the <code>PHONENUMBER</code> constraint might display as follows:</p> <TABLE BORDER="2"> <TR> <TD ROWSPAN="1" COLSPAN="1"> <pre><code> (408) 555-1212 </code></pre> </TD> </TR> </TABLE> <p>but the actual contents of the object visible to the application through the APIs would be the string "<code>4085551212</code>". The <code>size</code> method reflects the number of characters in the actual contents, not the number of characters that are displayed, so for this example the <code>size</code> method would return <code>10</code>.</p> <p>Some constraints, such as <code>DECIMAL</code>, require the implementation to perform syntactic validation of the contents of the text object. The syntax checking is performed on the actual contents of the text object, which may differ from the displayed contents as described above. Syntax checking is performed on the initial contents passed to the constructors, and it is also enforced for all method calls that affect the contents of the text object. The methods and constructors throw <code>IllegalArgumentException</code> if they would result in the contents of the text object not conforming to the required syntax.</p> <p>The value passed to the <A HREF="../../../javax/microedition/lcdui/TextField.html#setConstraints(int)"><CODE>setConstraints()</CODE></A> method consists of a restrictive constraint setting described above, as well as a variety of flag bits that modify the behavior of text entry and display. The value of the restrictive constraint setting is in the low order <code>16</code> bits of the value, and it may be extracted by combining the constraint value with the <code>CONSTRAINT_MASK</code> constant using the bit-wise <code>AND</code> (<code>&</code>) operator. The restrictive constraint settings are as follows: <blockquote><code> ANY<br> EMAILADDR<br> NUMERIC<br> PHONENUMBER<br> URL<br> DECIMAL<br> </code></blockquote> <p>The modifier flags reside in the high order <code>16</code> bits of the constraint value, that is, those in the complement of the <code>CONSTRAINT_MASK</code> constant. The modifier flags may be tested individually by combining the constraint value with a modifier flag using the bit-wise <code>AND</code> (<code>&</code>) operator. The modifier flags are as follows: <blockquote><code> PASSWORD<br> UNEDITABLE<br> SENSITIVE<br> NON_PREDICTIVE<br> INITIAL_CAPS_WORD<br> INITIAL_CAPS_SENTENCE<br> </code></blockquote> <a name="modes"></a> <h3>Input Modes</h3> <p>The <code>TextField</code> shares the concept of <em>input modes</em> with the <A HREF="../../../javax/microedition/lcdui/TextBox.html"><CODE>TextBox</CODE></A> class. The application can request that the implementation use a particular input mode when the user initiates editing of a <code>TextField</code> or <code>TextBox</code>. The input mode is a concept that exists within the user interface for text entry on a particular device. The application does not request an input mode directly, since the user interface for text entry is not standardized across devices. Instead, the application can request that the entry of certain characters be made convenient. It can do this by passing the name of a Unicode character subset to the <A HREF="../../../javax/microedition/lcdui/TextField.html#setInitialInputMode(java.lang.String)"><CODE>setInitialInputMode()</CODE></A> method. Calling this method requests that the implementation set the mode of the text entry user interface so that it is convenient for the user to enter characters in this subset. The application can also request that the input mode have certain behavioral characteristics by setting modifier flags in the constraints value. <p>The requested input mode should be used whenever the user initiates the editing of a <code>TextBox</code> or <code>TextField</code> object. If the user had changed input modes in a previous editing session, the application's requested input mode should take precedence over the previous input mode set by the user. However, the input mode is not restrictive, and the user is allowed to change the input mode at any time during editing. If editing is already in progress, calls to the <code>setInitialInputMode</code> method do not affect the current input mode, but instead take effect at the next time the user initiates editing of this text object. <p>The initial input mode is a hint to the implementation. If the implementation cannot provide an input mode that satisfies the application's request, it should use a default input mode. <P>The input mode that results from the application's request is not a restriction on the set of characters the user is allowed to enter. The user MUST be allowed to switch input modes to enter any character that is allowed within the current constraint setting. The constraint setting takes precedence over an input mode request, and the implementation may refuse to supply a particular input mode if it is inconsistent with the current constraint setting. <P>For example, if the current constraint is <code>ANY</code>, the call</P> <TABLE BORDER="2"> <TR> <TD ROWSPAN="1" COLSPAN="1"> <pre><code> setInitialInputMode("MIDP_UPPERCASE_LATIN"); </code></pre> </TD> </TR> </TABLE> <p>should set the initial input mode to allow entry of uppercase Latin characters. This does not restrict input to these characters, and the user will be able to enter other characters by switching the input mode to allow entry of numerals or lowercase Latin letters. However, if the current constraint is <code>NUMERIC</code>, the implementation may ignore the request to set an initial input mode allowing <code>MIDP_UPPERCASE_LATIN</code> characters because these characters are not allowed in a <code>TextField</code> whose constraint is <code>NUMERIC</code>. In this case, the implementation may instead use an input mode that allows entry of numerals, since such an input mode is most appropriate for entry of data under the <code>NUMERIC</code> constraint. <P>A string is used to name the Unicode character subset passed as a parameter to the <A HREF="../../../javax/microedition/lcdui/TextField.html#setInitialInputMode(java.lang.String)"><CODE>setInitialInputMode()</CODE></A> method. String comparison is case sensitive. <P>Unicode character blocks can be named by adding the prefix "<code>UCB</code>_" to the the string names of fields representing Unicode character blocks as defined in the J2SE class <code>java.lang.Character.UnicodeBlock</code>. Any Unicode character block may be named in this fashion. For convenience, the most common Unicode character blocks are listed below. <blockquote><code> UCB_BASIC_LATIN<br> UCB_GREEK<br> UCB_CYRILLIC<br> UCB_ARMENIAN<br> UCB_HEBREW<br> UCB_ARABIC<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -