ArrayIndexOutOfBoundsException when setting visibility to the caret
Hi all,
I made a JTextPane and run into some problems. I get an ArrayIndexOutOfBoundsException when I'm setting it's caret visibility to true and false:
JEditorPane textPane =new JTextPane;
// ....
// add the textPane to a frame's ContentPane
// ....
publicvoid test(){
for(int i = 0; i<100; i++){
testVisibility(true);
testVisibility(false);
}
}
privatevoid testVisibility(boolean b){
// This is were the exception will be thrown if the text pane is visible
// when making these calls.
textPane.setEditable(b);
textPane.getCaret().setVisible(b);
}
The snippet throws an ArrayIndexOutOfBoundsException:
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at javax.swing.text.BoxView.updateLayoutArray(BoxView.java:197)
at javax.swing.text.BoxView.replace(BoxView.java:168)
at javax.swing.text.View.append(View.java:432)
at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:412)
at javax.swing.text.FlowView.layout(FlowView.java:184)
at javax.swing.text.BoxView.setSize(BoxView.java:379)
at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
at javax.swing.text.BoxView.layout(BoxView.java:682)
at javax.swing.text.BoxView.setSize(BoxView.java:379)
at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1618)
at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:946)
at javax.swing.text.DefaultCaret.setVisible(DefaultCaret.java:952)
at org.seba.JTextPaneTest.testVisibility(JTextPaneTest.java:38)
at org.seba.JTextPaneTest.test(JTextPaneTest.java:29)
at org.seba.JTextPaneTest.main(JTextPaneTest.java:24)

