📄 textbox.html
字号:
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/TextBox.html#setInitialInputMode(java.lang.String)">setInitialInputMode</A></B>(<A HREF="../../../java/lang/String.html">String</A> characterSubset)</CODE>
<BR>
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>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/TextBox.html#setMaxSize(int)">setMaxSize</A></B>(int maxSize)</CODE>
<BR>
Sets the maximum size (number of characters) that can be contained in this <code>TextBox</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/TextBox.html#setString(java.lang.String)">setString</A></B>(<A HREF="../../../java/lang/String.html">String</A> text)</CODE>
<BR>
Sets the contents of the <code>TextBox</code> as a string value, replacing the previous contents.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/TextBox.html#setTicker(javax.microedition.lcdui.Ticker)">setTicker</A></B>(<A HREF="../../../javax/microedition/lcdui/Ticker.html">Ticker</A> ticker)</CODE>
<BR>
Sets a ticker for use with this <code>Displayable</code>, replacing any previous ticker.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/TextBox.html#setTitle(java.lang.String)">setTitle</A></B>(<A HREF="../../../java/lang/String.html">String</A> s)</CODE>
<BR>
Sets the title of the <code>Displayable</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/TextBox.html#size()">size</A></B>()</CODE>
<BR>
Gets the number of characters that are currently stored in this <code>TextBox</code>.</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_javax.microedition.lcdui.Displayable"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class javax.microedition.lcdui.<A HREF="../../../javax/microedition/lcdui/Displayable.html">Displayable</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../javax/microedition/lcdui/Displayable.html#addCommand(javax.microedition.lcdui.Command)">addCommand</A>, <A HREF="../../../javax/microedition/lcdui/Displayable.html#getHeight()">getHeight</A>, <A HREF="../../../javax/microedition/lcdui/Displayable.html#getTicker()">getTicker</A>, <A HREF="../../../javax/microedition/lcdui/Displayable.html#getTitle()">getTitle</A>, <A HREF="../../../javax/microedition/lcdui/Displayable.html#getWidth()">getWidth</A>, <A HREF="../../../javax/microedition/lcdui/Displayable.html#isShown()">isShown</A>, <A HREF="../../../javax/microedition/lcdui/Displayable.html#removeCommand(javax.microedition.lcdui.Command)">removeCommand</A>, <A HREF="../../../javax/microedition/lcdui/Displayable.html#setCommandListener(javax.microedition.lcdui.CommandListener)">setCommandListener</A>, <A HREF="../../../javax/microedition/lcdui/Displayable.html#sizeChanged(int, int)">sizeChanged</A></CODE></TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.<A HREF="../../../java/lang/Object.html">Object</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<!-- ========= 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="TextBox(java.lang.String, java.lang.String, int, int)"><!-- --></A><H3>
TextBox</H3>
<PRE>
public <B>TextBox</B>(<A HREF="../../../java/lang/String.html">String</A> title, <A HREF="../../../java/lang/String.html">String</A> text, int maxSize, int constraints)</PRE>
<DL>
<DD>Creates a new <code>TextBox</code> object with the given title string, initial contents, maximum size in characters, and constraints. If the text parameter is <code>null</code>, the <code>TextBox</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>title</CODE> - the title text to be shown with the display<DD><CODE>text</CODE> - the initial contents of the text editing area, <code>null</code> may be used to indicate no initial content<DD><CODE>maxSize</CODE> - the maximum capacity in characters. The implementation may limit boundary maximum capacity and the actually assigned capacity may me smaller than requested. A defensive application will test the actually given capacity with <A HREF="../../../javax/microedition/lcdui/TextBox.html#getMaxSize()"><CODE>getMaxSize()</CODE></A>.<DD><CODE>constraints</CODE> - see <a href="TextField.html#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 <code>constraints</code> 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>TextBox</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/TextBox.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>TextBox</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>TextBox</code>, or <code>null</code> if the <code>TextBox</code> 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/TextBox.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>TextBox</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/TextBox.html#setChars(char[], int, int)"><CODE>setChars(char[], int, int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setChars(char[], int, int)"><!-- --></A><H3>
setChars</H3>
<PRE>
public void <B>setChars</B>(char[] data, int offset, int length)</PRE>
<DL>
<DD>Sets the contents of the <code>TextBox</code> from a character array, replacing the previous contents. Characters are copied from the region of the <code>data</code> array starting at array index <code>offset</code> and running for <code>length</code> characters. If the data array is <code>null</code>, the <code>TextBox</code> is set to be empty and the other parameters are ignored. <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<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <code>offset</code> and <code>length</code> do not specify a valid range within the data array<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>data</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/TextBox.html#getChars(char[])"><CODE>getChars(char[])</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="insert(java.lang.String, int)"><!-- --></A><H3>
insert</H3>
<PRE>
public void <B>insert</B>(<A HREF="../../../java/lang/String.html">String</A> src, int position)</PRE>
<DL>
<DD>Inserts a string into the contents of the <code>TextBox</code>. The string is inserted just prior to the character indicated by the <code>position</code> parameter, where zero specifies the first character of the contents of the <code>TextBox</code>. If <code>position</code> is less than or equal to zero, the insertion occurs at the beginning of the contents, thus effecting a prepend operation. If <code>position</code> is greater than or equal to the current size of 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><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the resulting contents would be 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 insertion would exceed the current maximum capacity<DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -