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

Dialog

public class Dialog extends Object implements CommandListener
This class represents simple dialog form.

Fields Summary
public static final int
CANCELLED
Answer that indicates that the dialog was cancelled.
public static final int
CONFIRMED
Answer that indicates successful completion.
private com.sun.midp.lcdui.DisplayEventHandler
displayEventHandler
Caches the display manager reference.
private Command
okCmd
Command object for "OK" command.
private Command
cancelCmd
Command object for "Cancel" command.
private Object
preemptToken
Holds the preempt token so the form can end.
private int
answer
Holds the answer to the security question.
private Form
form
Form object for this dialog.
Constructors Summary
Dialog(String title, boolean withCancel)
Construct message dialog for informational message or confirmation request.

param
title dialog title
param
withCancel show Cancel button


                           
        

        form = new Form(title);
        form.addCommand(okCmd);
        if (withCancel) {
            form.addCommand(cancelCmd);
        }
        form.setCommandListener(this);
    
Methods Summary
voidappend(Item item)
Adds an Item into the Form.

param
item the Item to be added

        form.append(item);
    
public voidcommandAction(Command c, Displayable s)
Respond to a command issued on form. Sets the user's answer and notifies waitForAnswer and ends the form.

param
c command activiated by the user
param
s the Displayable the command was on.

        synchronized (this) {
            answer = c == okCmd ? CONFIRMED : CANCELLED;
            displayEventHandler.donePreempting(preemptToken);
            notify();
        }
    
intwaitForAnswer(com.sun.midp.security.SecurityToken token)
Waits for the user's answer.

param
token security token.
return
user's answer
throws
InterruptedException if interrupted

	if (displayEventHandler == null) {
	    displayEventHandler  = DisplayEventHandlerFactory
		.getDisplayEventHandler(token);
	}
        preemptToken = displayEventHandler.preemptDisplay(form, true);

        synchronized (this) {
            if (preemptToken == null) {
                return CANCELLED;
            }

            try {
                wait();
            } catch (Throwable t) {
                return CANCELLED;
            }

            return answer;
        }