Interface SourceListContextMenuProvider


public interface SourceListContextMenuProvider

An interface to hook into the context-menu showing process. When installed on a SourceList, this interface will be notified just prior to a context menu being shown.

Here's a sample implementation and installation of this interface:

 SourceListContextMenuProvider menuProvider = new SourceListContextMenuProvider() {
           public JPopupMenu createContextMenu() {
               // create and install your custom menu items for context-menu's on the SourceList.
               JPopupMenu menu = new JPopupMenu();
               popupMenu.add(new JMenuItem("Generic Menu for SourceList"));
               return popupMenu;
           }
           public JPopupMenu createContextMenu(JPopupMenu popupMenu, SourceListItem item) {
               // create and install your custom menu items for context-menu's on a SourceListItem.
               JPopupMenu menu = new JPopupMenu();
               popupMenu.add(new JMenuItem("Menu for " + item.getText()));
               return menu;
           }
           public JPopupMenu createContextMenu(SourceListCategory category) {
               // create and install your custom menu items for context-menu's on a SourceListCategory.
               JPopupMenu menu = new JPopupMenu();
               popupMenu.add(new JMenuItem("Menu for " + category.getText()));
               return menu;
           }
       };
 mySourceList.setSourceListContextMenuProvider(menuProvider);
 
  • Method Details

    • createContextMenu

      JPopupMenu createContextMenu()
      Called when the user requests that a context-menu be shown on the SourceList itself. This will only be called if the SourceList does not fill the entire view (doesn't have scroll bars) and the user clicks below any item or category. If the returned menu is null or if no menu items are added to the menu, then the menu will not be shown.
      Returns:
      the context menu for the associated SourceList. Can be null or have no menu items to indicate no menu should be shown.
    • createContextMenu

      JPopupMenu createContextMenu(SourceListItem item)
      Called when the user requests that a context-menu be shown on a SourceListItem. If the returned menu is null or if no menu items are added to the menu, then the menu will not be shown.
      Parameters:
      item - the SourceListItem that the context-menu was requested for.
      Returns:
      the context menu for the associated SourceListItem. Can be null or have no menu items to indicate no menu should be shown.
    • createContextMenu

      JPopupMenu createContextMenu(SourceListCategory category)
      Called when the user requests that a context-menu be shown on a SourceListCategory. If the returned menu is null or no menu items are added to the menu, then the menu will not be shown.
      Parameters:
      category - the SourceListCategory that the context-menu was requested for.
      Returns:
      the context menu for the associated SourceListCategory. Can be null or have no menu items to indicate no menu should be shown.