• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

About PopupMenus...

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm attempting to understand how to use popupmenus in my code but I keep getting:

"Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: parent is
null
at java.awt.PopupMenu.show(PopupMenu.java:149)
at PopupMenuTest$PopupListener.maybeShowPopup(PopupMenuTest.java:50)
at PopupMenuTest$PopupListener.mouseReleased(PopupMenuTest.java:45)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:2
90) etc..."

I'm using this to test:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;



Most of it I used actual snippets from java example codes, but it doesn't work!!

Can anyone tell me how to properly use popupmenus? I know I'm missing some crucial detail somewhere.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Most of it I used actual snippets from java example codes, but it doesn't work!!



Well then why don't you use the entire example to get it working. Then you remove bits and pieces one at a time if you think its not required and test again until you duplicate the problem.

Also, use the "Code" button to tag the posted code so it is properly formatted. You can edit your original posting to fix it.
 
Simone Li
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Camick wrote:

Most of it I used actual snippets from java example codes, but it doesn't work!!



Well then why don't you use the entire example to get it working. Then you remove bits and pieces one at a time if you think its not required and test again until you duplicate the problem.

Also, use the "Code" button to tag the posted code so it is properly formatted. You can edit your original posting to fix it.



Hmm... I've just tried adding the popupmenu to the parent component and now it works fine. Which is sorta strange, since the java example didn't add the popupmenu anywhere I can see.

Would you know whether it is necessary or not to add the popupmenu to a component?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic