wood burning stoves
The moose likes Java in General and the fly likes StateInvariantError infinite loop in formatting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "StateInvariantError infinite loop in formatting" Watch "StateInvariantError infinite loop in formatting" New topic

StateInvariantError infinite loop in formatting

Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Hi All,
Has anyone ever seen this error? I have a a JTextPane inside a JScrollPane set up in this manner:

I am reading some data from a file and then calling theTextArea.setText("" + allTheText);//allTheText is a StringBuffer
At first I thought I was getting this error because of the size of the data, but that is not so. What causes this error is when I am reading a file that looks like this: \\0034\\0023\\0056\\0026\\00e4\\00a3\\ etc... Here is the error I get and it happens when setText() method is called:
Exception occurred during event dispatching:
javax.swing.text.StateInvariantError: infinite loop in formatting
at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:429)
at javax.swing.text.FlowView.layout(FlowView.java:182)
at javax.swing.text.BoxView.setSize(BoxView.java:265)
at javax.swing.text.FlowView$FlowStrategy.insertUpdate(FlowView.java:315)
at javax.swing.text.FlowView.insertUpdate(FlowView.java:228)
at javax.swing.text.View.forwardUpdateToView(View.java:1094)
at javax.swing.text.View.forwardUpdate(View.java:1069)
at javax.swing.text.BoxView.forwardUpdate(BoxView.java:172)
at javax.swing.text.View.insertUpdate(View.java:648)
at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(BasicTextUI.java:13
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.ja
at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:179
at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:543)
at javax.swing.text.DefaultEditorKit.read(DefaultEditorKit.java:217)
at javax.swing.JEditorPane.setText(JEditorPane.java:1224)
at TextEditor$FileListener.openFile(TextEditor.java:941)
If anyone has a clue as to what is causing this, I would love to hear from you! Thanks in advance!!!

Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

I just figured out the problem! I did not have any line breaks. The file I was reading was just one continuous string without any new lines. When I went back and broke the text up with new lines, I could display the text just fine. If anyone has any other comments to make, they are welcome!
I agree. Here's the link: http://aspose.com/file-tools
subject: StateInvariantError infinite loop in formatting
jQuery in Action, 3rd edition