JMenu
, such as for example:public class MyMenuFactory extends AbstractMDIMenuFactory { protected void initMenus() { JMenu menu = new JMenu("Save File"); addToDynamicMenuMap("save", menu); } }The idea is to add elements in the menu (
AbstracAtion
, JMenuItem
, or JButton
depending on the nature of the selected tab. If it is not possible to add any element under the menu, the menu will be disabled.
AbstracAtion
, JMenuItem
, or JButton
, such as for example:public class MyMenuFactory extends AbstractMDIMenuFactory { protected void initMenus() { JMenu menu = new JMenu("File"); JMenuItem menuItem = new JMenuItem("Save"); addToDynamicMenuMap("save", menuItem); } }In that case, the element will be replaced by another one depending on the nature of the selected tab, or disabled if no element is available associated with the tab.
public class MyMenuFactory extends AbstractMDIMenuFactory { protected void initMenus() { JMenu menu = new JMenu("Save File"); addToDynamicMenuMap("save", menu); } }And in a MDIPlugin:
public class MyPlugin extends AbstractSwingMDIPlugin { private AbstractAction pluginAction = ... private MetaData meta = ... public void public Object getDynamicMenuElements(String menuKey, SwingFileProperties prop) { if (menuKey.equals("save") && prop.isCompatibleWith(meta)) { return pluginAction; } else { return null; } } }In this case the action will be added in the menu only if the selected element is compatible with the MetaData.
getDynamicMenuElements
method:getDynamicMenuElements
method is a boolean, the component associated with the key will be enabled or disabled depending on the value of the booleanJMenuItem
or JButton
:getDynamicMenuElements
method is an AbstracAtion
, this action will be associated with the button or menu itemgetDynamicMenuElements
method is a JMenuItem
or JButton
, it will replace the previous elementpublic class MyMenuFactory extends AbstractMDIMenuFactory { protected void initMenus() { JMenu menu = new JMenu("File"); JMenuItem item = new JMenu("Save As"); addToDynamicMenuMap("save", item); } }And in a MDIPlugin:
public class MyPlugin extends AbstractSwingMDIPlugin { private AbstractAction saveAction = ... private MetaData meta = ... public void public Object getDynamicMenuElements(String menuKey, SwingFileProperties prop) { if (menuKey.equals("save") && prop.isCompatibleWith(meta)) { return pluginAction; } else { return null; } } }In this case the action will be associated with the JMenuItem if the selected element is compatible with the MetaData.
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences