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

java.lang.Object
  extended by nu.zoom.swing.desktop.component.stringmenu.impl.StringMenuImpl<T>
All Implemented Interfaces:
StringMenu<T>, WorkbenchListener

public class StringMenuImpl<T extends Comparable<T> & Serializable>
extends Object
implements StringMenu<T>, WorkbenchListener


Method Summary
 void addItem(StringMenuItem<T> menuItem)
          Add an item to the beginning of the menu.
 void addListener(StringMenuListener<T> listener)
          Add a listener for selection events.
 void clear()
          Remove all items.
 void close()
           
 JMenu getJMenu(String menuName, Icon icon, String clearName, String clearTooltip)
          Get a menu of the items.
 int getNumberOfItems()
          Get the number of items on the menu.
 void removeItem(StringMenuItem<T> menuItem)
          Remove a named item.
 void removeListener(StringMenuListener<T> listener)
          Remove a listener.
 void start()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addListener

public void addListener(StringMenuListener<T> listener)
Description copied from interface: StringMenu
Add a listener for selection events.

Specified by:
addListener in interface StringMenu<T extends Comparable<T> & Serializable>

removeListener

public void removeListener(StringMenuListener<T> listener)
Description copied from interface: StringMenu
Remove a listener. Idempotent, i.e. you may remove the same listener several times or remove null to no effect.

Specified by:
removeListener in interface StringMenu<T extends Comparable<T> & Serializable>

getJMenu

public JMenu getJMenu(String menuName,
                      Icon icon,
                      String clearName,
                      String clearTooltip)
Description copied from interface: StringMenu
Get a menu of the items. The menu will be updated when items are added and removed. Will always return the same instance of the menu.

Specified by:
getJMenu in interface StringMenu<T extends Comparable<T> & Serializable>
Parameters:
menuName - The name of the menu.
icon - The icon to set for the menu, if null no icon will be used.
clearName - The name of the "clear all"-action at the top of the menu. If null the clear action will not be created.
clearTooltip - The tooltip to set for the clear action, if null no tooltip will be set.
Returns:
Return the instance of the JMenu this class wraps. Possibly empty menu, never null.

addItem

public void addItem(StringMenuItem<T> menuItem)
Description copied from interface: StringMenu
Add an item to the beginning of the menu. If the same item is added several times only one item will be created on the menu.

Specified by:
addItem in interface StringMenu<T extends Comparable<T> & Serializable>

removeItem

public void removeItem(StringMenuItem<T> menuItem)
Description copied from interface: StringMenu
Remove a named item. If the item is not on the menu this does nothing.

Specified by:
removeItem in interface StringMenu<T extends Comparable<T> & Serializable>

close

public void close()
Specified by:
close in interface WorkbenchListener

start

public void start()
Specified by:
start in interface WorkbenchListener

clear

public void clear()
Description copied from interface: StringMenu
Remove all items.

Specified by:
clear in interface StringMenu<T extends Comparable<T> & Serializable>

getNumberOfItems

public int getNumberOfItems()
Description copied from interface: StringMenu
Get the number of items on the menu.

Specified by:
getNumberOfItems in interface StringMenu<T extends Comparable<T> & Serializable>
Returns:
The number of items on the menu.


Copyright © 2011. All Rights Reserved.