1 19 20 package org.netbeans.modules.enode; 21 22 import javax.swing.*; 23 24 29 public class ComponentAction extends AbstractAction implements org.openide.util.actions.Presenter.Popup { 30 31 private JComponent myComponent; 32 33 34 public ComponentAction(JComponent comp) { 35 myComponent = comp; 36 } 37 38 41 public void actionPerformed(java.awt.event.ActionEvent e) { 42 throw new IllegalStateException ("ComponentAction should not be performed as action."); } 44 45 50 public JMenuItem getPopupPresenter() { 51 if (myComponent instanceof JMenuItem) { 52 return (JMenuItem)myComponent; 53 } 54 JMenuItem newItem = new JMenuItem(); 55 newItem.add(myComponent); 56 return newItem; 57 } 58 59 } 60 | Popular Tags |