Package com.explodingpixels.macwidgets
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 Summary
Modifier and TypeMethodDescriptionCalled when the user requests that a context-menu be shown on theSourceList
itself.createContextMenu
(SourceListCategory category) Called when the user requests that a context-menu be shown on aSourceListCategory
.Called when the user requests that a context-menu be shown on aSourceListItem
.
-
Method Details
-
createContextMenu
JPopupMenu createContextMenu()Called when the user requests that a context-menu be shown on theSourceList
itself. This will only be called if theSourceList
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
Called when the user requests that a context-menu be shown on aSourceListItem
. 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
- theSourceListItem
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
Called when the user requests that a context-menu be shown on aSourceListCategory
. If the returned menu is null or no menu items are added to the menu, then the menu will not be shown.- Parameters:
category
- theSourceListCategory
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.
-