Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JCombobox in JPopupMenu (NullPointerException)

1 view
Skip to first unread message

Uwe Clement

unread,
Mar 29, 2004, 5:08:10 AM3/29/04
to
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

unread,
Mar 30, 2004, 10:12:39 AM3/30/04
to
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

0 new messages