Class JMenuTracker

java.lang.Object
org.cytoscape.util.swing.JMenuTracker

public final class JMenuTracker extends Object
A class that creates and manages hierarchies of JMenu objects.

Cytoscape Backwards Compatibility (Final Class): This class is final and therefore can't be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.

Module: swing-util-api

To use this in your app, include the following dependency in your POM:

<dependency>
    <groupId>org.cytoscape</groupId>
    <artifactId>swing-util-api</artifactId>
</dependency>
  • Constructor Details

    • JMenuTracker

      public JMenuTracker(JPopupMenu rootPopupMenu)
      This constructor allows you to specify a root JPopupMenu that all parent-less menus will be added to. For example, if you call getMenu("File.New") then two menus will be created, "File" and it's submenu "New". In this situation the "File" menu will be added to the JPopupMenu, while "New" will not.
      Parameters:
      rootPopupMenu - the popup menu that all parent-less items will be added to based on their gravity
    • JMenuTracker

      public JMenuTracker(JMenuBar rootMenuBar)
      This constructor allows you to specify a root menubar that all parent-less menus will be added to. For example, if you call getMenu("File.New") then two menus will be created, "File" and it's submenu "New". In this situation the "File" menu will be added to the JPopupMenu, while "New" will not.
      Parameters:
      rootMenuBar - the popup menu that all parent-less items will be added to based on their gravity
  • Method Details

    • getGravityTracker

      public GravityTracker getGravityTracker(String menuString)
      This method will fetch an existing menu or create a new one if a menu with the specified name does not exist. The menu name is specified with a '.' delimited string, such that each token creates a new child menu. Insertion locations are determined in two possible ways: 1) a "gravity" or "weight" may be specified in square brackets after each item name. If the gravity has been omitted, the insertion location will be based on a case-insensitive alphanumeric ordering. An example of a string using weights is "File[10].New[40]".
      Parameters:
      menuString - A '.' delimited string identifying menu names.
      Returns:
      The last child JMenu object specified by the menu_string parameter.
    • removeGravityTracker

      public void removeGravityTracker(String menuName)
      Removes the MenuGravityTracker associated with the passed menu name.