JComboBox popup menu not appearing

微笑、不失礼 提交于 2019-12-06 08:56:44

I've had the similair problem with Java (1.6) on mac (10.5+) and it was due to the dialog the jCombobox appeared in was modal.

In my case the dropdown actually DID appear but as it was not that large it was not obvious that it was drawn behind the dialog :) so if you suspect this to be the case verify it by making the dropdown be long enough to appear below the component hiding it.

  • populate the dropdown with many items.
  • set its Specification to return a large enough number on "getMaximumRowCount".

Hope it helps.

I had the same issue and was wondering what was wrong, because usually it works and that kind of bug would be very very critical.

So I deleted everything that I just had a main-method with an JDialog with just an JComboBox within it.

The moment I had deleted everything I realized what I've done wrong: I used getRootPane() instead of getContentPane().

I usually use ESC for closing the dialog and add the KeyStroke to the rootPane. That was the reason for my careless mistake.

I hope that will help the next ones doing that mistake : )

I'm not sure if this is happening in your case, but a good portion of UI-related issues are due to the UI code not being run in the Event Dispatching Thread. Swing mandates that all code should be run in this thread or else you might suffer issues with GUIs not looking right or events not firing off properly, etc. If you are running all of this code in the Event Dispatching Thread then you can disregard this, otherwise check out this link:

http://download.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!