Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with JComboBox and change from v1.2.2 to 1.3.0  RSS feed

 
Erick Smith
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JComboBox that opens a JInternalFrame when any selection is made.
In the same panel I have a screen that changes a graphic when the user presser the mousebutton with the shift key held down.
Since I've migrated from v1.2.2 to 1.3.0 I have a runtime error that I can't seem to get rid of.
Here's the error:java.lang.NullPointerException
at javax.swing.JComboBox$DefaultKeySelectionManager.selectionForKey(Unknown Source)
at javax.swing.JComboBox.selectWithKeyChar(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI$KeyHandler.keyPressed(Unknown Source)
at java.awt.AWTEventMulticaster.keyPressed(Unknown Source)
at java.awt.Component.processKeyEvent(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.processKeyEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Now the problem seems to be that when the JComboBox is selected, it grabs the focus. Then when the user hits the shift key, the JComboBox tries to process the shift key.
I've tried setRequestFocusEnabled(false) in order to keep the JComboBox from grabbing the focus, but this doesn't seem to help.
Can anyone help with how to keep the JComboBox from pushing this error?
Thanks much,
Erick
 
Erick Smith
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could really use some help from anyone.
I have determined that the error is fired anytime the JCombobox has the focus and the shift key is pressed.
This also happens with my other JComboBox in the same JInternalFrame anytime it has the focus and the shift key is pressed.
I've tried preventing the JComboBox from getting the focus, but I've had no luck.
All I want is to know how to keep the error from happening, I don't need any keyboard events at all going to either of the JComboBoxes.
Does anyone know how to prevent modifier keys from doing this?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!