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

📄 textfield.java

📁 j2me polish学习的经典代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
//#if !polish.blackberry	implements CommandListener//#endif//#if polish.TextField.suppressCommands == true	//#define tmp.suppressCommands//#elif 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	 */	public static final int INITIAL_CAPS_SENTENCE = 0x200000;	/**	 * The mask value for determining the constraint mode. 	 * The application should	 * use the bit-wise <code>AND</code> operation with a value returned by	 * <code>getConstraints()</code> and	 * <code>CONSTRAINT_MASK</code> in order to retrieve the current	 * constraint mode,	 * in order to remove any modifier flags such as the	 * <code>PASSWORD</code> flag.	 * 	 * <P>Constant <code>0xFFFF</code> is assigned to	 * <code>CONSTRAINT_MASK</code>.</P></DL>	 * 	 * 	 */	public static final int CONSTRAINT_MASK = 0xFFFF;		//#ifndef tmp.suppressCommands		//#ifdef polish.i18n.useDynamicTranslations	  		protected static Command DELETE_CMD = new Command( Locale.get("polish.command.delete"), Command.CANCEL, 1 );		//#elifdef polish.command.delete:defined			//#= protected static final Command DELETE_CMD = new Command( "${polish.command.delete}", Command.CANCEL, 1 );		//#else			//# protected static final Command DELETE_CMD = new Command( "Delete", Command.CANCEL, 1 ); 		//#endif	//#endif	//#ifdef polish.i18n.useDynamicTranslations  		protected static Command CLEAR_CMD = new Command( Locale.get("polish.command.clear"), Command.ITEM, 2 );	//#elifdef polish.command.clear:defined		//#= protected static final Command CLEAR_CMD = new Command( "${polish.command.clear}", Command.ITEM, 2 );	//#else		//# protected static final Command CLEAR_CMD = new Command( "Clear", Command.ITEM, 2 ); 	//#endif		private int maxSize;	private int constraints;	//#ifdef polish.css.textfield-caret-color		private int caretColor = -1;	//#endif	private char editingCaretChar = '|';	protected char caretChar = '|';	//#ifdef polish.css.font-bitmap		private BitMapFontViewer editingCaretViewer;		private BitMapFontViewer caretViewer;	//#endif	protected boolean showCaret;	private long lastCaretSwitch;	private int originalWidth; // the content width according to the text	private int originalHeight; // the content height according to the text	protected String title;	private String passwordText;	private boolean isPassword;	private boolean enableDirectInput;	//#if (!tmp.suppressCommands && !tmp.supportsSymbolEntry) || tmp.supportsSymbolEntry

⌨️ 快捷键说明

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