File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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(
at javax.swing.text.FlowView.layout(
at javax.swing.text.BoxView.setSize(
at javax.swing.text.FlowView$FlowStrategy.insertUpdate(
at javax.swing.text.FlowView.insertUpdate(
at javax.swing.text.View.forwardUpdateToView(
at javax.swing.text.View.forwardUpdate(
at javax.swing.text.BoxView.forwardUpdate(
at javax.swing.text.View.insertUpdate(
at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.ja
at javax.swing.text.AbstractDocument.fireInsertUpdate(
at javax.swing.text.AbstractDocument.insertString(
at javax.swing.JEditorPane.setText(
at TextEditor$FileListener.openFile(
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:
subject: StateInvariantError infinite loop in formatting
It's not a secret anymore!