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!

Exception from "Unknown Source" using swing component, any debug tip ?

843807Mar 11 2010 — edited Mar 12 2010
Hello,

My application is based on swing, it contains a simple edit field, a javax.swing.JTextField.
Sometimes, I get an exception while selecting the text in it:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 9
at sun.font.FontDesignMetrics.charsWidth(Unknown Source)
at javax.swing.text.Utilities.getTabbedTextOffset(Unknown Source)
at javax.swing.text.Utilities.getTabbedTextOffset(Unknown Source)
at javax.swing.text.Utilities.getTabbedTextOffset(Unknown Source)
at javax.swing.text.PlainView.viewToModel(Unknown Source)
at javax.swing.text.FieldView.viewToModel(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$RootView.viewToModel(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI.viewToModel(Unknown Source)
at javax.swing.text.DefaultCaret.moveCaret(Unknown Source)
at javax.swing.text.DefaultCaret.mouseDragged(Unknown Source)
at java.awt.AWTEventMulticaster.mouseDragged(Unknown Source)
at java.awt.AWTEventMulticaster.mouseDragged(Unknown Source)
at java.awt.Component.processMouseMotionEvent(Unknown Source)
at javax.swing.JComponent.processMouseMotionEvent(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.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

I noticed it happens only when there is a space in the text, for example "123456"--> no problem, "123 456"--> exception.

As you can see, the exception is not directly a result of my code, so I am wandering how to debug this (I am not saying this is a bug of swing, it is likely to be a bug in my code, but how to find out ?)

my code has very few interaction with this control. in init stage I use getDocument().addDocumentListener, and in the document listener, I just use getText()
Is there any precaution to take with getText() ??
In the init stage, I also set a custom FocusTraversalPolicy (first time I play with that), could it be related to the exception ?

A detail on my app: it use the Swing Application Framework library and is built using NetBeans
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2010
Added on Mar 11 2010
5 comments
442 views