thinwire.ui
Class Menu.Item

java.lang.Object
  extended by thinwire.ui.Menu.Item
All Implemented Interfaces:
HierarchyComponent.Item<Menu,Menu.Item>
Enclosing class:
Menu

public static class Menu.Item
extends java.lang.Object

An object that represents an item in a Menu component.


Field Summary
static java.lang.String PROPERTY_ITEM_ENABLED
           
static java.lang.String PROPERTY_ITEM_KEY_PRESS_COMBO
           
 
Fields inherited from interface thinwire.ui.HierarchyComponent.Item
PROPERTY_ITEM_IMAGE, PROPERTY_ITEM_TEXT, PROPERTY_ITEM_USER_OBJECT
 
Constructor Summary
Menu.Item()
          Constructs a new Item with no text and no image.
Menu.Item(java.lang.String text)
          Constructs a new Item with the specified text and no image.
Menu.Item(java.lang.String text, java.lang.String image)
          Constructs a new Item with the specified text and image.
Menu.Item(java.lang.String text, java.lang.String image, java.lang.String keyPressCombo)
          Constructs a new Item with the specified text and image.
 
Method Summary
 java.util.List<I> getChildren()
          Get the List that contains the children of this item.
 H getHierarchy()
           
 java.lang.String getImage()
          Get the image file name that is displayed on the left side of the item.
 ImageInfo getImageInfo()
          Returns an immutable ImageInfo class that provides information about the assigned image, such as width, height, format, etc.
 int getIndex()
          A convenience method that returns the index of this item in it's parents children List.
 java.lang.String getKeyPressCombo()
          Get a text representation of the key combo that will activate this item.
 java.lang.Object getParent()
          Get the parent object of this item.
 java.lang.String getText()
          Get the text that is displayed for the item in the menu.
 java.lang.Object getUserObject()
          Get the user defined value for this item.
 boolean hasChildren()
           
 boolean isEnabled()
          Returns whether the item is selectable (enabled).
 void setEnabled(boolean enabled)
          Sets the enabled property of the item
 void setImage(java.lang.String image)
          Set the image file name that is displayed on the left side of the item.
 void setKeyPressCombo(java.lang.String keyPressCombo)
          Set the key combo / shortcut that will activate this item.
 void setText(java.lang.String text)
          Set the text that is displayed for the item in the menu.
 void setUserObject(java.lang.Object value)
          Set a user defined value for this item.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_ITEM_ENABLED

public static final java.lang.String PROPERTY_ITEM_ENABLED
See Also:
Constant Field Values

PROPERTY_ITEM_KEY_PRESS_COMBO

public static final java.lang.String PROPERTY_ITEM_KEY_PRESS_COMBO
See Also:
Constant Field Values
Constructor Detail

Menu.Item

public Menu.Item()
Constructs a new Item with no text and no image.


Menu.Item

public Menu.Item(java.lang.String text)
Constructs a new Item with the specified text and no image.

Parameters:
text - the text to display for the item.

Menu.Item

public Menu.Item(java.lang.String text,
                 java.lang.String image)
Constructs a new Item with the specified text and image.

Parameters:
text - the text to display for the item.
image - the image to display to the left of the text of the item.

Menu.Item

public Menu.Item(java.lang.String text,
                 java.lang.String image,
                 java.lang.String keyPressCombo)
Constructs a new Item with the specified text and image.

Parameters:
text - the text to display for the item.
image - the image to display to the left of the text of the item.
keyPressCombo - the key combination to associate to this Menu.Item.
Method Detail

isEnabled

public final boolean isEnabled()
Returns whether the item is selectable (enabled).

Returns:
true if the field is enabled (Default = true)

setEnabled

public final void setEnabled(boolean enabled)
Sets the enabled property of the item

Parameters:
enabled - True to make editable, false to disable the component (Default = true)

getKeyPressCombo

public java.lang.String getKeyPressCombo()
Get a text representation of the key combo that will activate this item.

Returns:
the text representation of the key combo that will activate this item, or an empty string if no key combo is set for this item.

setKeyPressCombo

public void setKeyPressCombo(java.lang.String keyPressCombo)
Set the key combo / shortcut that will activate this item. Once a key press combo is set, pressing the key combination within the window that this menu is attached to will cause the fireAction method to be called with the action set to "click".

Parameters:
keyPressCombo - key combo to assign to this item.
See Also:
KeyPressEvent.encodeKeyPressCombo(boolean, boolean, boolean, String)

toString

public java.lang.String toString()

getText

public java.lang.String getText()
Description copied from interface: HierarchyComponent.Item
Get the text that is displayed for the item in the menu.

Specified by:
getText in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the text that is displayed for the item, or an empty string if none.

setText

public void setText(java.lang.String text)
Description copied from interface: HierarchyComponent.Item
Set the text that is displayed for the item in the menu.

Specified by:
setText in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Parameters:
text - the text that should be displayed for the item.

getImage

public java.lang.String getImage()
Description copied from interface: HierarchyComponent.Item
Get the image file name that is displayed on the left side of the item.

Specified by:
getImage in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the image that is displayed for the item, or an empty string if none.

setImage

public void setImage(java.lang.String image)
Description copied from interface: HierarchyComponent.Item
Set the image file name that is displayed on the left side of the item.

Specified by:
setImage in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Parameters:
image - the name of the image file that should be displayed for the item.

getImageInfo

public ImageInfo getImageInfo()
Description copied from interface: HierarchyComponent.Item
Returns an immutable ImageInfo class that provides information about the assigned image, such as width, height, format, etc.

Specified by:
getImageInfo in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
an immutable ImageInfo describing this item's image.

getUserObject

public java.lang.Object getUserObject()
Description copied from interface: HierarchyComponent.Item
Get the user defined value for this item.

Specified by:
getUserObject in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the user defined value for this item if one is defined, null otherwise.

setUserObject

public void setUserObject(java.lang.Object value)
Description copied from interface: HierarchyComponent.Item
Set a user defined value for this item.

Specified by:
setUserObject in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>

getIndex

public int getIndex()
Description copied from interface: HierarchyComponent.Item
A convenience method that returns the index of this item in it's parents children List. Equivalent to item.getParent().getChildren().indexOf(item);.

Specified by:
getIndex in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the index of this item in it's parents children List.

getHierarchy

public H getHierarchy()
Specified by:
getHierarchy in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>

getParent

public java.lang.Object getParent()
Description copied from interface: HierarchyComponent.Item
Get the parent object of this item.

Specified by:
getParent in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
if this item is the root item, then this returns the Menu, otherwise this returns the parentMenu.Item or null if this item has not yet been added to another Menu.Item.

hasChildren

public boolean hasChildren()
Specified by:
hasChildren in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>

getChildren

public java.util.List<I> getChildren()
Description copied from interface: HierarchyComponent.Item
Get the List that contains the children of this item.

Specified by:
getChildren in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the List that contains the children of this item or an empty List if there are no children.


ThinWire® is a registered of Custom Credit Systems  Copyright © 2007 All rights reserved.
ThinWire_is_Open_Source_under_the_terms_of_the_LGPLv2.1 SourceForge.net_Project_Page java.net_Member Support_ThinWire,_Digg_our_Story