textboxexample.java

来自「j2me的1套UI框架,可以帮助开发者迅速的开发j2me应用程序.」· Java 代码 · 共 63 行

JAVA
63
字号
package org.j4me.examples.ui.components;

import org.j4me.ui.*;
import org.j4me.ui.components.*;

/**
 * Example of a <code>TextBox</code> component.
 */
public class TextBoxExample
	extends Dialog
{
	/**
	 * The previous screen.
	 */
	private DeviceScreen previous;
	
	/**
	 * The number box used by this example for entering phone numbers.
	 */
	private TextBox phoneNumber;
	
	/**
	 * A number box for entering a PIN.
	 */
	private TextBox pinNumber;
	
	/**
	 * Constructs a screen that shows a <code>TextBox</code> component in action.
	 * 
	 * @param previous is the screen to return to once this done.
	 */
	public TextBoxExample (DeviceScreen previous)
	{
		this.previous = previous;
		
		// Set the title and menu.
		setTitle( "TextBox Example" );
		setMenuText( "Back", null );

		// Add the phone number box.
		phoneNumber = new TextBox();
		phoneNumber.setLabel( "Phone Number" );
		phoneNumber.setForPhoneNumber();
		phoneNumber.setMaxSize( 10 );
		append( phoneNumber );
		
		// Add the PIN number box.
		pinNumber = new TextBox();
		pinNumber.setLabel( "PIN Number" );
		pinNumber.setForNumericOnly();
		pinNumber.setPassword( true );
		append( pinNumber );
	}

	/**
	 * Takes the user to the previous screen.
	 */
	protected void declineNotify ()
	{
		previous.show();
	}
}

⌨️ 快捷键说明

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