nu.zoom.swing.desktop.component.stringmenu
Interface StringMenu<T extends Comparable<T> & Serializable>

All Known Implementing Classes:
StringMenuImpl

public interface StringMenu<T extends Comparable<T> & Serializable>

A managed menu of items. The menu saves the items (but not the listeners) to the desktop preferences when the workbench quits. The menu restores itself when the getJMenu is first called. When a menu item is selected by the user all registered listeners will be called.


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.
 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.
 

Method Detail

addListener

void addListener(StringMenuListener<T> listener)
Add a listener for selection events.

Parameters:
listener -

removeListener

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

Parameters:
listener -

addItem

void addItem(StringMenuItem<T> menuItem)
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.

Parameters:
menuItem -

removeItem

void removeItem(StringMenuItem<T> menuItem)
Remove a named item. If the item is not on the menu this does nothing.

Parameters:
menuItem -

getJMenu

JMenu getJMenu(String menuName,
               Icon icon,
               String clearName,
               String clearTooltip)
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.

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.

getNumberOfItems

int getNumberOfItems()
Get the number of items on the menu.

Returns:
The number of items on the menu.

clear

void clear()
Remove all items.



Copyright © 2011. All Rights Reserved.