Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JComboBox/JMenu problem

843805Jan 8 2007 — edited Jan 11 2007
My app lists files in a directory and then adds these files into a combo box model. The combo box itself is placed inside a JMenu.
There are also two other items in the menu, 1) To add a file, 2) To remove a file. Both of these uses JFileChooser�s and both update the combo box, via the model.

The app seems to work fine. No exception is thrown running under 1.6, but under 1.4, the following is displayed:

java.lang.NullPointerException
at javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.grabContainer(BasicPopupMenuUI.java:383)
at javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.requestAddGrab(BasicPopupMenuUI.java:267)
at javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.stateChanged(BasicPopupMenuUI.java:323)
at javax.swing.MenuSelectionManager.fireStateChanged(MenuSelectionManager.java:161)
at javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager.java:87)
at javax.swing.JPopupMenu.setVisible(JPopupMenu.java:751)
at javax.swing.JPopupMenu.show(JPopupMenu.java:927)
at javax.swing.plaf.basic.BasicComboPopup.show(BasicComboPopup.java:177)
at javax.swing.plaf.basic.BasicComboPopup.togglePopup(BasicComboPopup.java:982)
at javax.swing.plaf.basic.BasicComboPopup$InvocationMouseHandler.mousePressed(BasicComboPopup.java:632)
at java.awt.Component.processMouseEvent(Component.java:5097)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3195)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

I don�t know if this will help, 1.4 is not used anymore, still the problem remains.

When the combo box is clicked, it should write to the console:

fav.addActionListener(new AbstractAction(){
public void actionPerformed(ActionEvent e)
{
System.out.println("Combo action");
/*// Copy to pl
((TrackList)favMod.getSelectedItem()).copyTo(plTrList);
// Make the pl outer
player.setOuterList(plTrList);
// Player from outer
player.setFromPlayer(false);
// Play
player.play();*/
}
});
Were �fav� is the JComboBox.

But the action isn�t called. Nor does the drop down list appear when the little arrow clicked. I have tried this app on 2 computers, and they both have the same problem.

Any help will be grand.

Luke
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 8 2007
Added on Jan 8 2007
4 comments
693 views