FileDocCategorySizeDatePackage
MessageDialog.javaAPI DocphoneME MR2 API (J2ME)4707Wed May 02 18:00:38 BST 2007com.sun.satsa.pki

MessageDialog

public class MessageDialog extends Object
Provides methods for simple messages and requests.

Fields Summary
Constructors Summary
Methods Summary
public static intchooseItem(com.sun.midp.security.SecurityToken token, java.lang.String title, java.lang.String label, java.lang.String[] list)
Displays dialog that allows user to select one element from the list.

param
token security token.
param
title dialog title
param
label list label
param
list elements of the list
return
-1 if user cancelled dialog, index of chosen item otherwise
throws
InterruptedException if interrupted


        Dialog d = new Dialog(title, true);
        ChoiceGroup choice =
                   new ChoiceGroup(label, Choice.EXCLUSIVE, list, null);
        d.append(choice);
        return d.waitForAnswer(token) == Dialog.CANCELLED ?
                   -1 : choice.getSelectedIndex();
    
public static java.lang.String[]enterNewPIN(com.sun.midp.security.SecurityToken token)
Displays dialog with new PIN parameters.

param
token security token.
return
array of strings or null if cancelled. Array contains new PIN label and PIN value.
throws
InterruptedException if interrupted


        Dialog d = new Dialog(
            // "New PIN", 
            Resource.getString(
                ResourceConstants.JSR177_PINDIALOG_TITLE_NEWPIN),
            true);

        TextField label = new TextField(
            // "PIN label ", 
            Resource.getString(
                ResourceConstants.JSR177_PINDIALOG_LABEL) + " ",
            "", 32, 0);
        TextField pin1 = new TextField(
            // "Enter PIN ", 
            Resource.getString(
                ResourceConstants.JSR177_PINDIALOG_ENTERPIN) + " ",
            "", 8, TextField.PASSWORD | TextField.NUMERIC);
        TextField pin2 = new TextField(
            // "Confirm PIN ", 
            Resource.getString(
                ResourceConstants.JSR177_PINDIALOG_CONFIRMPIN) + " ",
            "", 8, TextField.PASSWORD | TextField.NUMERIC);

        d.append(label);
        d.append(pin1);
        d.append(pin2);

        while (true) {
            if (d.waitForAnswer(token) == -1) {
                return null;
            }

            String s = label.getString().trim();
            if (s.equals("")) {
                continue;
            }

            String h1 = pin1.getString().trim();
            String h2 = pin2.getString().trim();

            if (h1.equals("") ||
                ! h1.equals(h2) ||
                h1.length() < 4) {
                pin1.setString("");
                pin2.setString("");
                continue;
            }
            return new String[] {s, h1};
        }
    
public static intshowMessage(com.sun.midp.security.SecurityToken token, java.lang.String title, java.lang.String message, boolean withCancel)
Displays dialog with informational message or confirmation request.

param
token security token.
param
title dialog title
param
message message text
param
withCancel show Cancel button
return
-1 if user cancelled dialog, 1 otherwise
throws
InterruptedException if interrupted


        Dialog d = new Dialog(title, withCancel);
        d.append(new StringItem(message, null));
        return d.waitForAnswer(token);