FileDocCategorySizeDatePackage
DisplayEventHandlerFactory.javaAPI DocphoneME MR2 API (J2ME)3030Wed May 02 18:00:24 BST 2007com.sun.midp.lcdui

DisplayEventHandlerFactory

public class DisplayEventHandlerFactory extends Object
This class works around the fact that public classes can not be added to a javax package by an implementation.

Fields Summary
private static DisplayEventHandler
managerImpl
The real implementation of the display event handler.
Constructors Summary
Methods Summary
public static voidSetDisplayEventHandlerImpl(DisplayEventHandler dm)
Set the implementation of the display manager, if one is not already set.

This implementation class will be in the as the Display class for security. But needs placed here to be visible to com.sun.midp classes.

param
dm reference to the system display manager

        if (managerImpl != null) {
            return;
        }

        managerImpl = dm;
    
public static DisplayEventHandlergetDisplayEventHandler(com.sun.midp.security.SecurityToken token)
Return a reference to the singleton display manager object.

param
token security token with the MIDP permission "allowed"
return
display manager reference.


        token.checkIfPermissionAllowed(Permissions.MIDP);

        if (managerImpl != null) {
            return managerImpl;
        }

        /**
         * The display manager implementation is a private class of Display
         * and is create in the class init of Display, we need to call a
         * static method of display to get the class init to run, because
         * some classes need to get the display manager to create a display
         */
        try {
            // this will yield a null pointer exception on purpose
            Display.getDisplay(null);
        } catch (NullPointerException npe) {
            // this is normal for this case, do nothing
        }

        return managerImpl;