⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textbox.java

📁 j2me polish学习的经典代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 * 
	 * @param data the source of the character data
	 * @param offset the beginning of the region of characters to copy
	 * @param length the number of characters to copy
	 * @throws ArrayIndexOutOfBoundsException if offset and length do not specify a valid range within the data array
	 * @throws IllegalArgumentException if data is illegal for the current input constraints
	 * 									or if the text would exceed the current maximum capacity
	 * @see #getChars(char[])
	 */
	public void setChars(char[] data, int offset, int length)
	{
		this.textField.setChars(data, offset, length);
	}

	/**
	 * 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
	 * (&quot;caret&quot;)
	 * 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>
	 * 
	 * @param src the String to be inserted
	 * @param position the position at which insertion is to occur
	 * @throws IllegalArgumentException if the resulting contents would be illegal for the current input constraints
	 * 									or if the insertion would exceed the current maximum capacity
	 * @throws NullPointerException if src is null
	 */
	public void insert( String src, int position)
	{
		this.textField.insert(src, position);
	}

	/**
	 * 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) &lt;= data.length</code>.</p>
	 * 
	 * @param data the source of the character data
	 * @param offset the beginning of the region of characters to copy
	 * @param length the number of characters to copy
	 * @param position the position at which insertion is to occur
	 * @throws ArrayIndexOutOfBoundsException if offset and length do not specify a valid range within the data array
	 * @throws IllegalArgumentException if the resulting contents would be illegal for the current input constraints
	 * 									or if the insertion would exceed the current maximum capacity
	 * @throws NullPointerException if data is null
	 */
	public void insert(char[] data, int offset, int length, int position)
	{
		this.textField.insert(data, offset, length, position);
	}

	/**
	 * 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) &lt;= size()</code>.</p>
	 * 
	 * @param offset the beginning of the region to be deleted
	 * @param length the number of characters to be deleted
	 * @throws IllegalArgumentException if the resulting contents would be illegal for the current input constraints
	 * @throws StringIndexOutOfBoundsException if offset and length do not specify a valid range within the contents of the TextBox
	 */
	public void delete(int offset, int length)
	{
		this.textField.delete(offset, length);
	}

	/**
	 * Returns the maximum size (number of characters) that can be
	 * stored in this <code>TextBox</code>.
	 * 
	 * @return the maximum size in characters
	 * @see #setMaxSize(int)
	 */
	public int getMaxSize()
	{
		return this.textField.getMaxSize();
	}

	/**
	 * 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.
	 * 
	 * @param maxSize the new maximum size
	 * @return assigned maximum capacity - may be smaller than requested.
	 * @throws IllegalArgumentException if maxSize is zero or less.
	 * 									Or if the contents after truncation would be illegal for the current input constraints
	 * @see #getMaxSize()
	 */
	public int setMaxSize(int maxSize)
	{
		return this.textField.setMaxSize(maxSize);
	}

	/**
	 * Gets the number of characters that are currently stored in this
	 * <code>TextBox</code>.
	 * 
	 * @return the number of characters
	 */
	public int size()
	{
		return this.textField.size();
	}

	/**
	 * 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.
	 * 
	 * @return the current caret position, 0 if at the beginning
	 */
	public int getCaretPosition()
	{
		return this.textField.getCaretPosition();
	}

	/**
	 * 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.
	 * 
	 * @param constraints see input constraints
	 * @throws IllegalArgumentException - if the value of the constraints parameter is invalid
	 * @see #getConstraints()
	 */
	public void setConstraints(int constraints)
	{
		this.textField.setConstraints(constraints);
	}

	/**
	 * Gets the current input constraints of the <code>TextBox</code>.
	 * 
	 * @return the current constraints value (see input constraints)
	 * @see #setConstraints(int)
	 */
	public int getConstraints()
	{
		return this.textField.getConstraints();
	}

	/**
	 * 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>
	 * 
	 * @param characterSubset a string naming a Unicode character subset, or null
	 * @since  MIDP 2.0
	 */
	public void setInitialInputMode( String characterSubset)
	{
		this.textField.setInitialInputMode(characterSubset);
	}

	/* (non-Javadoc)
	 * @see de.enough.polish.ui.Screen#createCssSelector()
	 */
	protected String createCssSelector() {
		return "textbox";
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -