问题
I am asking this question in reference to this post as I wasn't able to comment to the original post.
I used the code given in that post from @Hoki and mixed in my gui it is working fine. But sometimes i am getting following error
Error using test_gui>scroll_to_bottom (line 176)
Java exception occurred:
java.lang.IllegalArgumentException: bad position: 13319
at javax.swing.text.JTextComponent.setCaretPosition(Unknown Source)
Error in test_gui>commandWindowMirror (line 170)
scroll_to_bottom(h.f)
Error using test_gui>commandWindowMirror (line 166)
Java exception occurred:
javax.swing.text.BadLocationException: Invalid location
at javax.swing.text.GapContent.getChars(Unknown Source)
at javax.swing.text.GapContent.getString(Unknown Source)
at javax.swing.text.AbstractDocument.getText(Unknown Source)
at javax.swing.text.JTextComponent.getText(Unknown Source)
This always happens when I ask user to input something. My script ask users to enter some strings or values sometimes. But good thing is program doesnot crash it gives just error and when you press 'enter' again it returns to back position where it was stop. but scroll stops working and only when script is executed fully scroll comes to the last line. Any idea what might be causing this error and how to avoid it. Thank you.
来源:https://stackoverflow.com/questions/38478641/duplicate-matlab-command-window-to-gui