Customize menus in MapObjects-Java applications

Last Published: April 25, 2020


Instructions provided describe how to customize menus in MapObjects-Java applications. Menus in an application developed with MapObjects-Java can be modified at runtime using the plugin architecture.

This article explains the steps necessary to customize the menus in an application and uses JoViewPlus as an example. JoViewPlus is the extensive, fully-functional sample application that comes with MapObjects-Java.


The package contains a MenuManager class and MenuProvider interface that is used to customize menus. The MenuManager is responsible for reading a text file, creating the MenuProvider objects and providing a JMenu array. The MenuProvider interface uses the getMenus method to add custom items to the menu.

The following steps describe how to customize a menu:

  1. Implement the MenuProvider interface.

    All menus implement this interface. The MenuManager calls the getMenus and modifyMenus methods from this interface.

    In JoViewPlus, the interface is implemented in a single abstract class, JVPMenuProvider. All other menu classes inherit from a single class and are defined in the com.esri.jvp.plgin package. Those menus are: FileMenuProvider, EditMenuProvider, ViewMenuProvider, ToolsMenuProvider, WindowsMenuProvider and HelpMenuProvider.
  2. Create a META-INF/Services directory and text file.

    After finishing the MenuProvider classes, a text file needs to be defined. The name of the text file must be a class name that represents the type of all classes defined in the file. The file also must be placed under META-INF/services directory.

    In JoViewPlus, the file is named com.esri.jvp.JVPMenuProvider since all classes in the file are its subclasses. The contents are:

    #Notice the order corresponds to the menu location in JoViewPlus.

    Any of these menus can be added or removed or the order of the menus can be changed without having to recompile JoViewPlus. Therefore, depending on user privileges, certain features could be exposed or restricted without changing the code.

  3. Create an instance of MenuManager to load in the menus at run time.

    An instance of MenuManager is responsible for reading the service text files at run time. The META-INF/services directory and plugin classes should be included in the classpath, otherwise, the plugin classes are not be loaded.

    In JoViewPlus, the JVPMenuBar file handles this task. Its code is below:

    util.Iterator it = m_menuMgr.getProviders();
    JVPMenuProvider mp = null;
    while (it.hasNext()) {
    mp = (JVPMenuProvider);

    JMenu[] m = m_menuMgr.constructMenus();
    for (int i = 0; i < m.length; i++) {

    When the application is run, it reads the text file in the META-INF/Services directory to add the menus using the corresponding MenuProvider.

Article ID:000006710

  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic