Skip to main content


com.sun.lwuit
Class Command

java.lang.Object
  
extended by com.sun.lwuit.Command
All Implemented Interfaces:
ActionListener

public class Command
extends java.lang.Object
implements ActionListener

The action placed on the soft buttons and in the Menu on devices, similar to the MIDP command abstraction and Swing's Actions. Unlike the MIDP abstraction this class can be derived to implement the right behavior


Constructor Summary
Command(java.lang.String command)
          Creates a new instance of Command
Command(java.lang.String command, Image icon)
          Creates a new instance of Command
Command(java.lang.String command, Image icon, int id)
          Creates a new instance of Command
Command(java.lang.String command, int id)
          Creates a new instance of Command
 
Method Summary
 void actionPerformed(ActionEvent evt)
          This method is called when the soft button/Menu item is clicked
 boolean equals(java.lang.Object obj)
          compare two commands
 java.lang.Object getClientProperty(java.lang.String key)
          The client properties are a useful way to associate meta-data with a command without subclassing
 java.lang.String getCommandName()
          gets the Command Name
 Image getDisabledIcon()
          Indicates the icon that is displayed on the button when the button is in the disabled state
 Image getIcon()
          Returns the icon representing the command
 int getId()
          Return the command ID
 Image getPressedIcon()
          Indicates the icon that is displayed on the button when the button is in pressed state
 Image getRolloverIcon()
          Indicates the icon that is displayed on the button when the button is in rolled over state
 int hashCode()
          Allows storing commands in a vector/hashtable
 boolean isEnabled()
          Allows disabling/enabling the command
 void putClientProperty(java.lang.String key, java.lang.Object value)
          The client properties are a useful way to associate meta-data with a command without sub classing
 void setCommandName(java.lang.String command)
          sets the Command name
 void setDisabledIcon(Image disabledIcon)
          Indicates the icon that is displayed on the button when the button is in the disabled state
 void setEnabled(boolean enabled)
          Allows disabling/enabling the command
 void setPressedIcon(Image pressedIcon)
          Indicates the icon that is displayed on the button when the button is in pressed state
 void setRolloverIcon(Image rolloverIcon)
          Indicates the icon that is displayed on the button when the button is in rolled over state
 java.lang.String toString()
          Returns a string representation of the object
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Command

public Command(java.lang.String command)
Creates a new instance of Command

Parameters:
command - the string that will be placed on the Soft buttons\Menu

Command

public Command(java.lang.String command,
               Image icon)
Creates a new instance of Command

Parameters:
command - the string that will be placed on the Soft buttons\Menu
icon - the icon representing the command

Command

public Command(java.lang.String command,
               int id)
Creates a new instance of Command

Parameters:
command - the string that will be placed on the Soft buttons\Menu
id - user defined ID for a command simplifying switch statement code working with a command

Command

public Command(java.lang.String command,
               Image icon,
               int id)
Creates a new instance of Command

Parameters:
command - the string that will be placed on the Soft buttons\Menu
icon - the icon representing the command
id - user defined ID for a command simplifying switch statement code working with a command
Method Detail

getId

public int getId()
Return the command ID

Returns:
the command ID

getCommandName

public java.lang.String getCommandName()
gets the Command Name

Returns:
the Command name

setCommandName

public void setCommandName(java.lang.String command)
sets the Command name

Parameters:
command -

getIcon

public Image getIcon()
Returns the icon representing the command

Returns:
an icon representing the command

toString

public java.lang.String toString()
Returns a string representation of the object

Overrides:
toString in class java.lang.Object
Returns:
Returns a string representation of the object

getPressedIcon

public Image getPressedIcon()
Indicates the icon that is displayed on the button when the button is in pressed state

Returns:
icon used

getDisabledIcon

public Image getDisabledIcon()
Indicates the icon that is displayed on the button when the button is in the disabled state

Returns:
icon used

getRolloverIcon

public Image getRolloverIcon()
Indicates the icon that is displayed on the button when the button is in rolled over state

Returns:
icon used

setRolloverIcon

public void setRolloverIcon(Image rolloverIcon)
Indicates the icon that is displayed on the button when the button is in rolled over state

Parameters:
rolloverIcon - icon to use

setPressedIcon

public void setPressedIcon(Image pressedIcon)
Indicates the icon that is displayed on the button when the button is in pressed state

Parameters:
pressedIcon - icon used

setDisabledIcon

public void setDisabledIcon(Image disabledIcon)
Indicates the icon that is displayed on the button when the button is in the disabled state

Parameters:
disabledIcon - icon used

equals

public boolean equals(java.lang.Object obj)
compare two commands

Overrides:
equals in class java.lang.Object
Parameters:
obj - a Command Object to compare
Returns:
true if the obj has the same command name

hashCode

public int hashCode()
Allows storing commands in a vector/hashtable

Overrides:
hashCode in class java.lang.Object
Returns:
unique hashcode for the command class

actionPerformed

public void actionPerformed(ActionEvent evt)
This method is called when the soft button/Menu item is clicked

Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - the Event Object

isEnabled

public boolean isEnabled()
Allows disabling/enabling the command

Returns:
the enabled

setEnabled

public void setEnabled(boolean enabled)
Allows disabling/enabling the command

Parameters:
enabled - the enabled to set

getClientProperty

public java.lang.Object getClientProperty(java.lang.String key)
The client properties are a useful way to associate meta-data with a command without subclassing

Parameters:
key - an arbitrary user key
Returns:
an arbitrary user object

putClientProperty

public void putClientProperty(java.lang.String key,
                              java.lang.Object value)
The client properties are a useful way to associate meta-data with a command without sub classing

Parameters:
key - an arbitrary user key
value - an arbitrary user object, null to remove


Copyright 2011 Oracle Corporation. All rights reserved. Use is subject to license terms.
 
 
Close
loading
Please Confirm
Close