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

📄 faketextfieldcustomitem.java

📁 j2me polish学习的经典代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
//#condition polish.LibraryBuild/* * Copyright (c) 2004-2005 Robert Virkus / Enough Software * * This file is part of J2ME Polish. * * J2ME Polish is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *  * J2ME Polish is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with J2ME Polish; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *  * Commercial licenses are also available, please * refer to the accompanying LICENSE.txt or visit * http://www.j2mepolish.org for details. */package de.enough.polish.ui;import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.Graphics;import de.enough.polish.util.BitMapFontViewer;import de.enough.polish.util.Locale;//#if polish.blackberryimport de.enough.polish.blackberry.ui.PolishEditField;import net.rim.device.api.ui.Field;import net.rim.device.api.ui.FieldChangeListener;import net.rim.device.api.ui.UiApplication;import net.rim.device.api.ui.XYRect;import net.rim.device.api.ui.component.BasicEditField;//#endif/** * Meant for classes that want to be compatible with javax.microedition.lcdui.CustomItem for IDEs only while extending de.enough.polish.ui.StringItem in reality. *  * <p>Subclasses can change the hierarchy with preprocessing like this: * <pre> * public class MyCustomItem * //#if polish.LibraryBuild * 		 extends FakeStringCustomItem * //#else * 		//# extends StringItem * //#endif	  * </pre> * </p> * <p>This allows subclasses to access all fields and methods of the J2ME Polish item class.</p> * <p>Note that this class can never be used in reality. Ever.</p> *  * @since J2ME Polish 1.3 * @author Robert Virkus, robert@enough.de */public class FakeTextFieldCustomItem extends FakeStringCustomItem//#if polish.TextField.useDirectInput && !polish.blackberry	//#define tmp.forceDirectInput	//#define tmp.directInput//#elif polish.css.textfield-direct-input && !polish.blackberry	//#define tmp.directInput	//#define tmp.allowDirectInput//#endif//#if polish.TextField.supportSymbolsEntry && tmp.directInput	//#define tmp.supportsSymbolEntry	//#if !polish.css.style.textFieldSymbolTable && !polish.css.style.textFieldSymbolList 		//#abort You need to define the ".textFieldSymbolList" CSS style when enabling the polish.TextField.supportSymbolsEntry option. 	//#endif//#endif//#if !polish.blackberry	implements CommandListener//#endif//#if polish.TextField.suppressCommands == true	//#define tmp.suppressCommands// //#elif (tmp.forceDirectInput || polish.blackberry)  && !tmp.supportsSymbolEntry// 	//# implements ItemCommandListener//#else	, ItemCommandListener//#endif//#if polish.blackberry and polish.TextField.suppressCommands	//# implements FieldChangeListener//#elif polish.blackberry  	//# , FieldChangeListener//#endif{	/**	 * The user is allowed to enter any text.	 * <A HREF="Form.html#linebreak">Line breaks</A> may be entered.	 * 	 * <P>Constant <code>0</code> is assigned to <code>ANY</code>.</P></DL>	 * 	 */	public static final int ANY = 0;	/**	 * The user is allowed to enter an e-mail address.	 * 	 * <P>Constant <code>1</code> is assigned to <code>EMAILADDR</code>.</P></DL>	 * 	 */	public static final int EMAILADDR = 1;	/**	 * The user is allowed to enter only an integer value. The implementation	 * must restrict the contents either to be empty or to consist of an	 * optional minus sign followed by a string of one or more decimal	 * numerals.  Unless the value is empty, it will be successfully parsable	 * using <A HREF="../../../java/lang/Integer.html#parseInt(java.lang.String)"><CODE>Integer.parseInt(String)</CODE></A>.	 * 	 * <P>The minus sign consumes space in the text object.  It is thus	 * impossible to enter negative numbers into a text object whose maximum	 * size is <code>1</code>.</P>	 * 	 * <P>Constant <code>2</code> is assigned to <code>NUMERIC</code>.</P></DL>	 * 	 */	public static final int NUMERIC = 2;	/**	 * The user is allowed to enter a phone number. The phone number is a	 * special	 * case, since a phone-based implementation may be linked to the	 * native phone	 * dialing application. The implementation may automatically start a phone	 * dialer application that is initialized so that pressing a single key	 * would be enough to make a call. The call must not made automatically	 * without requiring user's confirmation.  Implementations may also	 * provide a feature to look up the phone number in the device's phone or	 * address database.	 * 	 * <P>The exact set of characters allowed is specific to the device and to	 * the device's network and may include non-numeric characters, such as a	 * &quot;+&quot; prefix character.</P>	 * 	 * <P>Some platforms may provide the capability to initiate voice calls	 * using the <A HREF="../../../javax/microedition/midlet/MIDlet.html#platformRequest(java.lang.String)"><CODE>MIDlet.platformRequest</CODE></A> method.</P>	 * 	 * <P>Constant <code>3</code> is assigned to <code>PHONENUMBER</code>.</P></DL>	 * 	 */	public static final int PHONENUMBER = 3;	/**	 * The user is allowed to enter a URL.	 * 	 * <P>Constant <code>4</code> is assigned to <code>URL</code>.</P></DL>	 * 	 */	public static final int URL = 4;	/**	 * The user is allowed to enter numeric values with optional decimal	 * fractions, for example &quot;-123&quot;, &quot;0.123&quot;, or	 * &quot;.5&quot;.	 * 	 * <p>The implementation may display a period &quot;.&quot; or a	 * comma &quot;,&quot; for the decimal fraction separator, depending on	 * the conventions in use on the device.  Similarly, the implementation	 * may display other device-specific characters as part of a decimal	 * string, such as spaces or commas for digit separators.  However, the	 * only characters allowed in the actual contents of the text object are	 * period &quot;.&quot;, minus sign &quot;-&quot;, and the decimal	 * digits.</p>	 * 	 * <p>The actual contents of a <code>DECIMAL</code> text object may be	 * empty.  If the actual contents are not empty, they must conform to a	 * subset of the syntax for a <code>FloatingPointLiteral</code> as defined	 * by the <em>Java Language Specification</em>, section 3.10.2.  This	 * subset syntax is defined as follows: the actual contents	 * must consist of an optional minus sign	 * &quot;-&quot;, followed by one or more whole-number decimal digits,	 * followed by an optional fraction separator, followed by zero or more	 * decimal fraction digits.  The whole-number decimal digits may be	 * omitted if the fraction separator and one or more decimal fraction	 * digits are present.</p>	 * 	 * <p>The syntax defined above is also enforced whenever the application	 * attempts to set or modify the contents of the text object by calling	 * a constructor or a method.</p>	 * 	 * <p>Parsing this string value into a numeric value suitable for	 * computation is the responsibility of the application.  If the contents	 * are not empty, the result can be parsed successfully by	 * <code>Double.valueOf</code> and related methods if they are present	 * in the runtime environment. </p>	 * 	 * <p>The sign and the fraction separator consume space in the text	 * object.  Applications should account for this when assigning a maximum	 * size for the text object.</p>	 * 	 * <P>Constant <code>5</code> is assigned to <code>DECIMAL</code>.</P>	 * 	 * 	 * @since MIDP 2.0	 */	public static final int DECIMAL = 5;	/**	 * Indicates that the text entered is confidential data that should be	 * obscured whenever possible.  The contents may be visible while the	 * user is entering data.  However, the contents must never be divulged	 * to the user.  In particular, the existing contents must not be shown	 * when the user edits the contents.  The means by which the contents	 * are obscured is implementation-dependent.  For example, each	 * character of the data might be masked with a	 * &quot;<code>*</code>&quot; 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>	 * 	 */	public static final int PASSWORD = 0x10000;	/**	 * 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>.	 * 	 * 	 * @since MIDP 2.0	 */	public static final int UNEDITABLE = 0x20000;	/**	 * 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>	 * 	 * 	 * @since MIDP 2.0	 */	public static final int SENSITIVE = 0x40000;	/**	 * 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>	 * 	 * 	 * @since MIDP 2.0	 */	public static final int NON_PREDICTIVE = 0x80000;	/**	 * 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>.	 * 	 * 	 * @since MIDP 2.0	 */	public static final int INITIAL_CAPS_WORD = 0x100000;	/**	 * 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>.	 * 	 * 	 * @since MIDP 2.0

⌨️ 快捷键说明

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