The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Illegal Cast

Posted by John Mac on January 21, 2002 at 6:49 PM

Just like the error message says. You made a illegal cast.

javax.swing.text.StateInvariantError: Illegal cast to MutableAttributeSet

> Hi!

> When I try play with DefaultStyledDocument's element structure I get the following Error:

> javax.swing.text.StateInvariantError: Illegal cast to MutableAttributeSet
> at javax.swing.text.AbstractDocument$AbstractElement.checkForIllegalCast(
> at javax.swing.text.AbstractDocument$AbstractElement.addAttributes(
> at javax.swing.text.AbstractDocument$AbstractElement.(
> at javax.swing.text.AbstractDocument$LeafElement.(
> at javax.swing.text.AbstractDocument.createLeafElement(
> at javax.swing.text.DefaultStyledDocument$ElementBuffer.fractureDeepestLeaf(
> at javax.swing.text.DefaultStyledDocument$ElementBuffer.insertUpdate(
> at javax.swing.text.DefaultStyledDocument$ElementBuffer.insert(

> What have I done wrong?
> Is it illegal to use MutableAttributeSets?
> How can I get Im-MutableAttributeSets? It seems very complicated since most of the instantiable classes implement MutableAttributeSet.

> Regards,
> Laura

  • stfu morpheus February 13, 2002 at 1:32 PM (0)

Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us