// create the menus with the Application menu factory mfactory = new SimpleMenuFactory(); mfactory.createDefaultMDISettings("Settings"); super.preparePanels(4, true, true, mfactory);The settings is a MDISettings, which is a sub-interface of Action.
public class SimpleMenuFactory extends AbstractMDIMenuFactory { private final JMenu settingsmenu = new JMenu("Settings"); public SimpleMenuFactory() { } @Override protected void initMenus() { registerMenus(); // create settings menu settingsmenu.add(createDefaultMDISettings("Settings")); Mbar.add(settingsmenu); } }
MDISettingsNode
component which will be shown on the right of the panel, and which can be either any JComponent
, or a MDISettingsNode elementJPanel panel = new JPanel(); JCheckBox cb = new JCheckBox("Tick Me!"): panel.add(cb); settings.addNode("General", node);
MDISettings settings = this.getMDISettings(); JButton fileButton = new JButton("..."); MDISettingsNode.Single node = new MDISettingsNode.Single(fileButton, "Directory");
maxWidthSpinner = new JSpinner(maxWidthModel); maxWidthSpinner.setEditor(new JSpinner.NumberEditor(maxWidthSpinner, "####")); maxWidthSpinner.setMaximumSize(maxWidthSpinner.getPreferredSize()); MDISettingsNode.Single nodeLimitWidth = new MDISettingsNode.Single(maxWidthSpinner, "Max Width"); MDISettingsNode.Single nodeMaxWidth = new MDISettingsNode.Single(limitWidthCb, "Limit Width"); MDISettingsNode.Multiple node = new MDISettingsNode.Multiple(nodeLimitWidth, nodeMaxWidth);
MDISettings settings = this.getMDISettings(); JButton fileButton = new JButton("..."); fileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectDirectory(); } }); MDISettingsNode.Single node = new MDISettingsNode.Single(fileButton, "Directory"); settings.addNode("General", node);
public class OpenImagePlugin extends AbstractMDIPlugin { private MDISettingsNode settingsNode; private JSpinner maxWidthSpinner; private final JCheckBox limitWidthCb = new JCheckBox(); public OpenImagePlugin() { } @Override public void register(MDIApplication app) throws Exception { super.register(app); maxWidthSpinner = new JSpinner(maxWidthModel); MDISettingsNode.Single nodeLimitWidth = new MDISettingsNode.Single(maxWidthSpinner, "Max Width"); MDISettingsNode.Single nodeMaxWidth = new MDISettingsNode.Single(limitWidthCb, "Limit Width"); settingsNode = new MDISettingsNode.Multiple(nodeLimitWidth, nodeMaxWidth); } @Override public void resetSettings() { maxWidthSpinner.setValue(pluginConf.maxWidth); limitWidthCb.setSelected(pluginConf.limitWidth); } @Override public Object getStaticMenuElements(String menu) { if (menu.equals(PluginElementTypes.SETTINGS)) { return settingsNode; } else { return null; } } }
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences