-5

Why could be a possible reason for:

JTextPane p = new JTextPane();
p.setText("hello");

The exact code is rather long. So I'm not sure what parts I must show here.

It's something like:

Tab t = new Tab(jp1);
t.editortxt.setText("hello");

Tab extends JPanel and has in its constructor:

editortxt = new JTextPane();

i.e., editortxt is a property of Tab.

It throws this:

java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:371)
at java.util.ArrayList.get(ArrayList.java:384)

I mean why would something so abstract throw when I use its own API?

batman
  • 5,022
  • 11
  • 52
  • 82

1 Answers1

0

Verify are you passing correct index to ArrayList.get() method. It looks you are accessing the element from ArrayList that have size is zero.

Prabhakaran Ramaswamy
  • 25,706
  • 10
  • 57
  • 64