Changes between Version 12 and Version 13 of PluginMenu


Ignore:
Timestamp:
Mar 8, 2013, 12:03:49 PM (11 years ago)
Author:
marie
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PluginMenu

    v12 v13  
    3838}}}
    3939
    40 The second interface, Plugin3D, is more general, and simply supports a setup and cleanup method.
     40The second interface, Plugin3D, is more general, and simply supports a setup and cleanup method. The example below adds a new menu and menu item to the user interface for illustration.
     41{{{
     42public class HelloPlugin3D implements Plugin3D {
     43    JMenu helloMenu;
     44    MorphAnalyser2 morph;
     45   
     46    public boolean setup(MorphAnalyser2 morphanalyser) {
     47        morph = morphanalyser;
     48        helloMenu = new JMenu("Hello");
     49        morphanalyser.addMenu(helloMenu);
     50        JMenuItem helloItem = new JMenuItem("Hello");
     51        helloItem.addActionListener(new ActionListener() {
     52
     53            public void actionPerformed(ActionEvent e) {
     54                JOptionPane.showMessageDialog(morph, "Hello");
     55            }
     56
     57        });
     58        helloMenu.add(helloItem);
     59        return true;
     60    }
     61
     62    public boolean cleanup(MorphAnalyser2 morphanalyser) {
     63        morphanalyser.removeMenu(helloMenu);
     64        return true;
     65    }
     66
     67}
     68}}}
    4169
    4270'''Using Factories'''