Home
Categories
Dictionary
Download
Project Details
Changes Log
Tutorials
FAQ
License

Menu factory



The MDIMenuFactory and its abstract implementation AbstractMDIMenuFactory allows to manage menus in a GUI application. Note that there is only one MDIMenuFactory for the application.

Implementing the menu factory

The only method you need to implement is the AbstractMDIMenuFactory.initMenus() method. This method allows to create menus under the menuBar and Toolbars under the Toolbar panel of the application:

Adding a Splash screen

The MDIMenuFactory.setProgressInterface(ProgressInterface) allows to add a component which will show the progress of the initialization of the application before the application has fully started.

The SplashScreen is a default Swing progress interface which allows to show a Splash screen with a background image, and the version and date of the application.

Adding the menu factory to the application

To use the menu factory in the application, you need to call one of the following methods: These methods should be called after the application configuration has been initialized and the plugins have been registered.

For example:
  public class SimpleMDI extends AbstractMDIApplication {
    public SimpleMDI() {
      super("MDISimpleExample");

      // plugins will be in the same directory as the main application jar
      pluginsDir = new File(System.getProperty("user.dir"));

      // initialize configuration without Preferences
      this.initConfiguration();
      // register plugins in the plugins directory (same as main application jar directory)
      this.registerPlugins();

      // create the menus with the Application menu factory
      mfactory = new SimpleMenuFactory();
      // in this case:
      // - there is a default message area with 5 lines
      // - there is a toolbar
      // - there is a status bar
      super.preparePanels(4, true, true, mfactory);
      // set the size of the Application window
      this.setSize(500, 500);
    }
  }

Adding menus to the application GUI in the application

Two fields maintain the menubar and the toolbar of the application: You can use the menubar and the toolbar as you wish in the menu factory.

Adding menus and toolbar buttons to the application GUI in Plugins


If you want to add menus in Plugins, you need to make the application high-level menus available by the application.

There are several ways to do that:

Adding an About dialog

Main Article: About dialog

Updating menus at runtime

Main Article: MDIPlugin

It is possible to update the menus at runtime by implementing the MDIMenuFactory.updateMenus() method. This method can also be called by the GUIApplication.updateMenus(MDIPlugin) method:
updatemenus

See also


Categories: gui | swing

Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences