Popuppublic 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 void | main(java.lang.String[] args)
Show.inFrame(new Popup(),200,150);
| protected void | processMouseEvent(java.awt.event.MouseEvent e)
if (e.isPopupTrigger())
popup.show(
e.getComponent(), e.getX(), e.getY());
else super.processMouseEvent(e);
|
|