40 | | The second interface, Plugin3D, is more general, and simply supports a setup and cleanup method. |
| 40 | The 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 | {{{ |
| 42 | public 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 | }}} |