Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

StateInvariantError infinite loop in formatting

 
Barry Andrews
Ranch Hand
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
38)
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.ja
va:1562)
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
 
Barry Andrews
Ranch Hand
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic