nu.zoom.swing.desktop.component.stringmenu
Class StringMenuItem<T extends Comparable<T> & Serializable>

java.lang.Object
  extended by nu.zoom.swing.desktop.component.stringmenu.StringMenuItem<T>
Type Parameters:
T - The value type. Must be comparable since it is used when comparing the menu items and serializable since it is stored in the Preferences to persist menus.
All Implemented Interfaces:
Serializable, Comparable<T>

public class StringMenuItem<T extends Comparable<T> & Serializable>
extends Object
implements Comparable<T>, Serializable

Holds information about a menu item. A menu item is a presentation name, which is shown on the menu, and a value. When a menu is selected the value is used in callbacks to indicate which menu was selected.

See Also:
Serialized Form

Constructor Summary
StringMenuItem(T value, String presentationName)
          Create a new menu item.
 
Method Summary
 int compareTo(T o)
          Compares this menu item to another by delegating to this items value for comparison.
 boolean equals(Object obj)
          Two menu items are considered the same if their values are equal.
 String getPresentationName()
           
 T getValue()
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringMenuItem

public StringMenuItem(T value,
                      String presentationName)
Create a new menu item.

Parameters:
value - The value of the menu, may not be null.
presentationName - The string that is shown on the menu. If null the default is to take toString on the value and truncating if too long.
Method Detail

getPresentationName

public String getPresentationName()
Returns:
the presentationName

getValue

public T getValue()
Returns:
the value

equals

public boolean equals(Object obj)
Two menu items are considered the same if their values are equal. This comparison ignores the presentationName.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(T o)
Compares this menu item to another by delegating to this items value for comparison.

Specified by:
compareTo in interface Comparable<T extends Comparable<T> & Serializable>
See Also:
Comparable.compareTo(java.lang.Object)


Copyright © 2011. All Rights Reserved.