FileDocCategorySizeDatePackage
Popup.javaAPI DocExample3517Mon Apr 06 18:10:26 BST 1998c13.swing

Popup

public class Popup extends JPanel

Fields Summary
JPopupMenu
popup
JTextField
t
Constructors Summary
public Popup()

    
    add(t);
    ActionListener al = new ActionListener() {
      public void actionPerformed(ActionEvent e){
        t.setText(
          ((JMenuItem)e.getSource()).getText());
      }
    };
    JMenuItem m = new JMenuItem("Hither");
    m.addActionListener(al);
    popup.add(m);
    m = new JMenuItem("Yon");
    m.addActionListener(al);
    popup.add(m);
    m = new JMenuItem("Afar");
    m.addActionListener(al);
    popup.add(m);
    popup.addSeparator();
    m = new JMenuItem("Stay Here");
    m.addActionListener(al);
    popup.add(m);
    enableEvents(AWTEvent.MOUSE_EVENT_MASK);
  
Methods Summary
public static voidmain(java.lang.String[] args)

    Show.inFrame(new Popup(),200,150);
  
protected voidprocessMouseEvent(java.awt.event.MouseEvent e)

    if (e.isPopupTrigger())
      popup.show(
        e.getComponent(), e.getX(), e.getY());
    else super.processMouseEvent(e);