On Sat, 28 Nov 1998, Thomas Okken wrote:

> 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.

add(mypopup);


Cheers
John Summerfield
http://os2.ami.com.au/os2/ for OS/2 support.
Configuration, networking, combined IBM ftpsites index.

Reply via email to