Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Text field: password

Use a password field when BlackBerry device users are required to type a password. You can apply filters to restrict the characters that users can type in the field. By default, the password field supports all characters.

Class

PasswordEditField

Supported since

BlackBerry Java SDK 4.2.1

More information

For more information about password fields, see the UI Guidelines.

Example

This screen shows a password field.

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.PasswordEditField;


public class PasswordEditFieldDemo extends UiApplication
{
    public static void main(String[] args) 
    {
        PasswordEditFieldDemo theApp = new PasswordEditFieldDemo();
        theApp.enterEventDispatcher();
    }
    
    public PasswordEditFieldDemo()
    {
        pushScreen(new PasswordEditFieldDemoScreen());
    }
}

class PasswordEditFieldDemoScreen extends MainScreen
{
    public PasswordEditFieldDemoScreen()
    {
        setTitle("Password Field Demo");
        
        BasicEditField enterUsername = new BasicEditField("Username: ", "");
        PasswordEditField enterPIN = new PasswordEditField(
                                        "PIN: ", "", 4, PasswordEditField.FILTER_NUMERIC);
        
        add(enterUsername);
        add(enterPIN);
    }
}