FileDocCategorySizeDatePackage
PopupLayer.javaAPI DocphoneME MR2 API (J2ME)5477Wed May 02 18:00:20 BST 2007com.sun.midp.chameleon.layers

PopupLayer

public class PopupLayer extends CLayer
A "Popup" layer is a special kind of layer which can also have commands associated with it. When a popup layer is added to a MIDPWindow, its commands (if it has any) can be accessed through the soft button bar. If a popup layer does have commands associated with it, any commands on the current displayable/item are no longer accessible. If the popup layer does not have its own commands, any existing commands from the displayable/item remain. NOTE: For now, a PopupLayer is also always visible, that is isVisible() always returns true. To control the visibility of a PopupLayer, you add it and remove it from a MIDPWindow. IMPL_NOTE: determine if a relationship between PopupLayer and MIDPWindow can allow non visible popup layers.

Fields Summary
protected Command[]
commands
The set of Commands for this PopupLayer
protected CommandListener
listener
The CommandListener to notify when a Command is selected
Constructors Summary
public PopupLayer()
Construct a new PopupLayer. By default, setSupportsInput() is set to true.

        this((Image)null, -1);
    
public PopupLayer(Image bgImage, int bgColor)
Construct a new PopupLayer, given a background image. By default, setSupportsInput() is set to true, and so is setVisible().

        super(bgImage, bgColor);
        this.supportsInput = true;
    
public PopupLayer(Image[] bgImage, int bgColor)
Construct a new PopupLayer, given a 9 pc background image. By default, setSupportsInput() is set to true, and so is setVisible().

        super(bgImage, bgColor);
        this.supportsInput = true;
    
Methods Summary
public CommandListenergetCommandListener()
Get the CommandListener associated with this popup layer. If the listener is null, any commands added to this popup layer will not be visible when this popup is added to a MIDPWindow.

return
the CommandListener (if any) associated with this popup

        return listener;
    
public Command[]getCommands()
Get the set of Commands associated with this PopupLayer

return
the set of Commands associated with this PopupLayer. 'null' means there are no Commands.

        return commands;
    
public booleanhandlePoint(int x, int y)
Returns true for popup layer because almost all pointer events have to be handled by popup even if it's out of bounds. The most of popups has to be closed if the pointer event is out of its bounds. The exception is the pointer is a part of the command layer.

param
x the "x" coordinate of the point
param
y the "y" coordinate of the point
return
true if the point is handled by this layer

        boolean ret = true;
        if (commands != null && commands.length > 0 && owner != null) {
            ret = !((MIDPWindow)owner).belongToCmdLayers(x, y);
        }
        return ret | containsPoint(x, y);
    
public voidsetCommandListener(CommandListener listener)
Establish a listener for the commands for this popup layer. NOTE: When the CommandListener is notified of a command action, the 'displayable' argument in its commandAction() method will always be null.

param
listener the CommandListener to call when a command on this popup layer is selected

        this.listener = listener;
    
public voidsetCommands(Command[] commands)
Set the set of Commands associated with this PopupLayer.

param
commands the set of Commands associated with this PopupLayer. 'null' means there are no Commands

        this.commands = commands;
    
public voidsetVisible(boolean visible)
The setVisible() method is overridden in PopupLayer so as not to have any effect. PopupLayers are always visible by their very nature. In order to hide a PopupLayer, it should be removed from its containing MIDPWindow.