📄 textbox.html
字号:
the contents, the insertion occurs immediately after the end of the contents, thus effecting an append operation. For example, <code>text.insert(s, text.size())</code> always appends the string <code>s</code> to the current contents. <p>The current size of the contents is increased by the number of inserted characters. The resulting string must fit within the current maximum capacity. </p> <p>If the application needs to simulate typing of characters it can determining the location of the current insertion point ("caret") using the with <A HREF="../../../javax/microedition/lcdui/TextBox.html#getCaretPosition()"><CODE>getCaretPosition()</CODE></A> method. For example, <code>text.insert(s, text.getCaretPosition())</code> inserts the string <code>s</code> at the current caret position.</p><DD><DL><DT><B>Parameters:</B><DD><CODE>src</CODE> - the <code>String</code> to be inserted<DD><CODE>position</CODE> - the position at which insertion is to occur<DT><B>Throws:</B><DD><CODE>IllegalArgumentException</CODE> - if the resulting contents would be illegal for the current <a href="TextField.html#constraints">input constraints</a><DD><CODE>IllegalArgumentException</CODE> - if the insertion would exceed the current maximum capacity<DD><CODE>NullPointerException</CODE> - if <code>src</code> is <code>null</code></DL></DD></DL><HR><A NAME="insert(char[], int, int, int)"><!-- --></A><H3>insert</H3><PRE>public void <B>insert</B>(char[] data, int offset, int length, int position)</PRE><DL><DD>Inserts a subrange of an array of characters into the contents of the <code>TextBox</code>. The <code>offset</code> and <code>length</code> parameters indicate the subrange of the data array to be used for insertion. Behavior is otherwise identical to <A HREF="../../../javax/microedition/lcdui/TextBox.html#insert(java.lang.String, int)"><CODE>insert(String, int)</CODE></A>. <p>The <code>offset</code> and <code>length</code> parameters must specify a valid range of characters within the character array <code>data</code>. The <code>offset</code> parameter must be within the range <code>[0..(data.length)]</code>, inclusive. The <code>length</code> parameter must be a non-negative integer such that <code>(offset + length) <= data.length</code>.</p><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - the source of the character data<DD><CODE>offset</CODE> - the beginning of the region of characters to copy<DD><CODE>length</CODE> - the number of characters to copy<DD><CODE>position</CODE> - the position at which insertion is to occur<DT><B>Throws:</B><DD><CODE>ArrayIndexOutOfBoundsException</CODE> - if <code>offset</code> and <code>length</code> do not specify a valid range within the data array<DD><CODE>IllegalArgumentException</CODE> - if the resulting contents would be illegal for the current <a href="TextField.html#constraints">input constraints</a><DD><CODE>IllegalArgumentException</CODE> - if the insertion would exceed the current maximum capacity<DD><CODE>NullPointerException</CODE> - if <code>data</code> is <code>null</code></DL></DD></DL><HR><A NAME="delete(int, int)"><!-- --></A><H3>delete</H3><PRE>public void <B>delete</B>(int offset, int length)</PRE><DL><DD>Deletes characters from the <code>TextBox</code>. <p>The <code>offset</code> and <code>length</code> parameters must specify a valid range of characters within the contents of the <code>TextBox</code>. The <code>offset</code> parameter must be within the range <code>[0..(size())]</code>, inclusive. The <code>length</code> parameter must be a non-negative integer such that <code>(offset + length) <= size()</code>.</p><DD><DL><DT><B>Parameters:</B><DD><CODE>offset</CODE> - the beginning of the region to be deleted<DD><CODE>length</CODE> - the number of characters to be deleted<DT><B>Throws:</B><DD><CODE>IllegalArgumentException</CODE> - if the resulting contents would be illegal for the current <a href="TextField.html#constraints">input constraints</a><DD><CODE>StringIndexOutOfBoundsException</CODE> - if <code>offset</code> and <code>length</code> do not specify a valid range within the contents of the <code>TextBox</code></DL></DD></DL><HR><A NAME="getMaxSize()"><!-- --></A><H3>getMaxSize</H3><PRE>public int <B>getMaxSize</B>()</PRE><DL><DD>Returns the maximum size (number of characters) that can be stored in this <code>TextBox</code>.<DD><DL><DT><B>Returns:</B><DD>the maximum size in characters<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/TextBox.html#setMaxSize(int)"><CODE>setMaxSize(int)</CODE></A></DL></DD></DL><HR><A NAME="setMaxSize(int)"><!-- --></A><H3>setMaxSize</H3><PRE>public int <B>setMaxSize</B>(int maxSize)</PRE><DL><DD>Sets the maximum size (number of characters) that can be contained in this <code>TextBox</code>. If the current contents of the <code>TextBox</code> are larger than <code>maxSize</code>, the contents are truncated to fit.<DD><DL><DT><B>Parameters:</B><DD><CODE>maxSize</CODE> - the new maximum size<DT><B>Returns:</B><DD>assigned maximum capacity - may be smaller than requested.<DT><B>Throws:</B><DD><CODE>IllegalArgumentException</CODE> - if <code>maxSize</code> is zero or less.<DD><CODE>IllegalArgumentException</CODE> - if the contents after truncation would be illegal for the current <a href="TextField.html#constraints">input constraints</a><DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/TextBox.html#getMaxSize()"><CODE>getMaxSize()</CODE></A></DL></DD></DL><HR><A NAME="size()"><!-- --></A><H3>size</H3><PRE>public int <B>size</B>()</PRE><DL><DD>Gets the number of characters that are currently stored in this <code>TextBox</code>.<DD><DL><DT><B>Returns:</B><DD>the number of characters</DL></DD></DL><HR><A NAME="getCaretPosition()"><!-- --></A><H3>getCaretPosition</H3><PRE>public int <B>getCaretPosition</B>()</PRE><DL><DD>Gets the current input position. For some UIs this may block and ask the user for the intended caret position, and on other UIs this may simply return the current caret position.<DD><DL><DT><B>Returns:</B><DD>the current caret position, <code>0</code> if at the beginning</DL></DD></DL><HR><A NAME="setConstraints(int)"><!-- --></A><H3>setConstraints</H3><PRE>public void <B>setConstraints</B>(int constraints)</PRE><DL><DD>Sets the input constraints of the <code>TextBox</code>. If the current contents of the <code>TextBox</code> do not match the new constraints, the contents are set to empty.<DD><DL><DT><B>Parameters:</B><DD><CODE>constraints</CODE> - see <a href="TextField.html#constraints">input constraints</a><DT><B>Throws:</B><DD><CODE>IllegalArgumentException</CODE> - if the value of the constraints parameter is invalid<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/TextBox.html#getConstraints()"><CODE>getConstraints()</CODE></A></DL></DD></DL><HR><A NAME="getConstraints()"><!-- --></A><H3>getConstraints</H3><PRE>public int <B>getConstraints</B>()</PRE><DL><DD>Gets the current input constraints of the <code>TextBox</code>.<DD><DL><DT><B>Returns:</B><DD>the current constraints value (see <a href="TextField.html#constraints">input constraints</a>)<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/TextBox.html#setConstraints(int)"><CODE>setConstraints(int)</CODE></A></DL></DD></DL><HR><A NAME="setInitialInputMode(java.lang.String)"><!-- --></A><H3>setInitialInputMode</H3><PRE>public void <B>setInitialInputMode</B>(String characterSubset)</PRE><DL><DD>Sets a hint to the implementation as to the input mode that should be used when the user initiates editing of this <code>TextBox</code>. The <code>characterSubset</code> parameter names a subset of Unicode characters that is used by the implementation to choose an initial input mode. If <code>null</code> is passed, the implementation should choose a default input mode. <p>See <a href="TextField#modes">Input Modes</a> for a full explanation of input modes. </p><DD><DL><DT><B>Parameters:</B><DD><CODE>characterSubset</CODE> - a string naming a Unicode character subset, or <code>null</code><DT><B>Since: </B><DD>MIDP 2.0</DD></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_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/TextBox.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>MIDP 2.0</strong></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/microedition/lcdui/StringItem.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/microedition/lcdui/TextField.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="TextBox.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="mailto:jsr-118-comments@jcp.org">Send a comment or suggestion</a> Version 2.0 of Mobile Information Device Profile Specification<br>Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright 1993-2002 Sun Microsystems, Inc. and Motorola, Inc. All Rights Reserved. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -