Skip to main content

Auto complete throwing exception.

3 replies [Last post]
navinkjha
Offline
Joined: 2004-12-28
Points: 0

I have an editable combobox in which I attach a custom PlainDocument to the editor (JTextField) to restrict the number of characters that can be entered. I see that AutoCompleteDocument has a method:

public Element getParagraphElement(int pos) {
return ((StyledDocument) delegate).getParagraphElement(pos);
}

The delegate here may not be a StyledDocument as is the case for me. This method throws a class cast exception for that reason. It only happens when you doubled on the selected text. I guess only then StyledDocument interface methods get called. Below is the complete stacktrace:

2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: AutoCompleteDocument.getParagraphElement(SourceFile:289)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at javax.swing.text.Utilities.getParagraphElement(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at javax.swing.text.Utilities.getWordStart(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at javax.swing.text.DefaultEditorKit$BeginWordAction.actionPerformed(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at javax.swing.text.DefaultEditorKit$SelectWordAction.actionPerformed(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at javax.swing.text.DefaultCaret.selectWord(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at javax.swing.text.DefaultCaret.mousePressed(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Component.processMouseEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at javax.swing.JComponent.processMouseEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Component.processEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Container.processEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Component.dispatchEventImpl(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Container.dispatchEventImpl(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Component.dispatchEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Container.dispatchEventImpl(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Window.dispatchEventImpl(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.Component.dispatchEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.EventQueue.dispatchEvent(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
2008-12-18 09:34:22,897 [AWT-EventQueue-0] ERROR System.err - at java.awt.EventDispatchThread.run(Unknown Source)
-Navin

Message was edited by: navinkjha

Message was edited by: navinkjha

Message was edited by: navinkjha

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kschaefe
Offline
Joined: 2006-06-08
Points: 0

This is an old and resolved bug. Please use the latest weekly and verify that the problem is solved.

Karl

navinkjha
Offline
Joined: 2004-12-28
Points: 0

Thanks Karl,
I had changed my custom Document to extend StyledDocument and that worked also (since it implements the right interface). I will go ahead and update to the latest build. Can I pick a stable build rather than a weekly build ?

kschaefe
Offline
Joined: 2006-06-08
Points: 0

You can grab any build since about 12/15.

Karl