JCombobox in JPopupMenu (NullPointerException)

From: Uwe Clement (clement_at_gmx.de)
Date: 03/29/04


Date: Mon, 29 Mar 2004 12:08:10 +0200

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)
===================================================================



Relevant Pages

  • Combination of JCombobox and a menu
    ... type entries newt/frog/toad for example, and they'd display as a menu, ... JCombobox said that it used a JPopupMenu, ... JPopupMenu involves replacing a large part of the combobox UI if its to ...
    (comp.lang.java.softwaretools)
  • Re: jcombobox custom renderer
    ... int index, boolean isSelected, boolean cellHasFocus) { ... Does anyone know what I need to do to get the jcombobox editor to display the Section's description? ...
    (comp.lang.java.programmer)
  • Re: JCombobox custom Popup
    ... > How can i make a Combo box (JComboBox) display a custom control as ... > popup. ...
    (comp.lang.java.gui)
  • Problem JComboBox Editable getInputMap
    ... I am using JComboBox. ... public void actionPerformed ... case DELETION: ... case DISPLAY: ...
    (comp.lang.java.gui)
  • Setting Opaque false on JComboBox
    ... the posts on the subject are rather outdated. ... primary concern is the display line and the drop down. ... I've already tried breaking the JComboBox down into it's components; ... The Panel is transparent, the button is not. ...
    (comp.lang.java.gui)