Hi all,

[ I apologize if this message appears twice on the list. I tried to send
it yesterday, but
my ISP had some problem, and I sent it from the office instead, but it
didn't show up on
the digest, so I figure something went wrong... ]

I'm trying to make a PopupMenu appear in a Component (a subclass of
Canvas, to be precise).
I create the menu in my Component's constructor:

mypopup = new PopupMenu();
mypopup.add("Blah");
// etc...
mypopup.addActionListener(this);

In my processMouseEvent method, I check for mouse clicks in a certain
place, and then I try to pop up the menu by saying

mypopup.show(this, X, Y);

The result is this:

Exception occurred during event dispatching:
java.lang.NullPointerException: parent is null
        at java.awt.PopupMenu.show(PopupMenu.java:92)
        at MyComponent.processMouseEvent(MyComponent.java:358)
        at java.awt.Component.processEvent(Component.java:2249)
        at java.awt.Component.dispatchEventImpl(Component.java:1781)
        at java.awt.Component.dispatchEvent(Component.java:1708)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:81)

The documentation for PopupMenu.show() mentions a "parent", but I can't
figure out how to
set it.
I must be missing something obvious, but I don't see it... Your help
would be greatly
apprectiated!

Thanks,

 - Tom

Reply via email to