Name

Displayable

Synopsis

Displayable is an abstract base class for objects that can be shown by a Display.

The addCommand() method provides the ability to associate one or more Commands with the displayable object. The way in which these Commands are represented in the user interface is platform-dependent, but would normally involve one or both of a button and a menu item. A Command may be removed using the removeCommand() method.

The setCommandListener() allows a single CommandListener to be registered to be notified when a Command is activated. If this method is called when a listener is already registered, the original listener is removed and will not receive further event notifications. Calling this method with argument null removes any registered listener.

The isShown() method can be used to determine whether the Displayable is currently visible. This method returns true when the owning MIDlet is in the foreground and the Displayable is the object currently displayed by its Display.

public abstract class Displayable {
// No Constructor
                    
// Public Instance Methods
   public void addCommand( Command cmd);  
   public boolean isShown();  
   public void removeCommand( Command cmd);  
   public void setCommandListener( CommandListener l);  
}

Subclasses

Canvas, Screen

Passed To

CommandListener.commandAction(), Display.setCurrent()

Returned By

Display.getCurrent()

Get J2ME in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.