Esempio n. 1
0
 private void addMenuItem(
     JMenu menu,
     String label,
     int mnemonic,
     String accessibleDescription,
     String actionCallbackName)
     throws NoSuchMethodException {
   JMenuItem menuItem = new JMenuItem(label, mnemonic);
   menuItem
       .getAccessibleContext()
       .setAccessibleDescription((accessibleDescription != null) ? accessibleDescription : label);
   final Method callback =
       getClass().getMethod(actionCallbackName, new Class[] {ActionEvent.class});
   menuItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           try {
             callback.invoke(WordListScreen.this, new Object[] {e});
           } catch (InvocationTargetException ex) {
             handleException(ex.getTargetException());
           } catch (IllegalAccessException ex) {
             handleException(ex);
           }
         }
       });
   menu.add(menuItem);
 }