Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2004

Tip: Looking for answers? Try searching our database.

JCombobox in JPopupMenu (NullPointerException)

Thread view: 
Uwe Clement - 29 Mar 2004 11:08 GMT
HI there,

i want to display a jcombobox withhin a jpopupmenu.

----------------------------------------------------------------------------
-----
JPopupMenu menu = new JPopupMenu();
JComboBox box = new JComboBox();
...
menu.add(box);
menu.show(frame, 0,0);
----------------------------------------------------------------------------
-----

after opening the popupmenu of the combobox i will get a
nullpointerexception.

is there no way to display two popupmenues at the same time ?
see the exception log below.

many thanks i advance !

uwe clement

===================================================================
java.lang.NullPointerException
       at
javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.grabContainer(Ba
sicPopupMenuUI.java:344)
       at
javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.requestAddGrab(B
asicPopupMenuUI.java:227)
       at
javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.stateChanged(Bas
icPopupMenuUI.java:273)
       at
javax.swing.MenuSelectionManager.fireStateChanged(MenuSelectionManage
r.java:158)
       at
javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager
.java:86)
       at javax.swing.JPopupMenu.setVisible(JPopupMenu.java:741)
       at javax.swing.JPopupMenu.show(JPopupMenu.java:912)
       at
javax.swing.plaf.basic.BasicComboPopup.show(BasicComboPopup.java:177)

       at
javax.swing.plaf.basic.BasicComboPopup.togglePopup(BasicComboPopup.ja
va:982)
       at
javax.swing.plaf.basic.BasicComboPopup$InvocationMouseHandler.mousePr
essed(BasicComboPopup.java:632)
       at
java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:21
8)
       at java.awt.Component.processMouseEvent(Component.java:5090)
       at java.awt.Component.processEvent(Component.java:4890)
       at java.awt.Container.processEvent(Container.java:1566)
       at java.awt.Component.dispatchEventImpl(Component.java:3598)
       at java.awt.Container.dispatchEventImpl(Container.java:1623)
       at java.awt.Component.dispatchEvent(Component.java:3439)
       at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
)
       at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3162)

       at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
       at java.awt.Container.dispatchEventImpl(Container.java:1609)
       at java.awt.Window.dispatchEventImpl(Window.java:1585)
       at java.awt.Component.dispatchEvent(Component.java:3439)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
       at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:197)
       at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
       at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

       at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

       at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
===================================================================
Todd Corley - 30 Mar 2004 16:12 GMT
You may want to rethink your design.  

This is the "Java Look and Feel Guidline" html version:
http://java.sun.com/products/jlf/ed1/dg/index.htm

Read chapter 9 about menus.  

You may want to take the items in the combox and dynamicly creat a
menu or if you are stuck with the combo box, add it as a component to
a JOption pane for showing.

Hope this helps,
Todd


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.