<Swing Dev> Extension method for AbstractDocument.Content?

Paulo Levi i30817 at gmail.com
Thu Jun 21 04:56:24 UTC 2012

Hi. I've noticed that DefaultStyledDocument has a slowness issue when
inserting text. Even if you subclass it and expose the faster method:
protected void insert(int offset, ElementSpec[] data)

the body of the method still uses a stringbuilder to append all char[]
inside of the data before actually inserting into the content.

This is because the only method for insertion in the default content
interface is:
public UndoableEdit insertString(int where, String str)

Now if there are going to be extension methods in java 8, it would be nice
to have a
public UndoableEdit insert(int where, int index, int length, char[] str)
default {
   return insert(where, new String(index, length, str);

with a adequate specialization in GapContent (that obviously doesn't call
the string version), and that that new method is used in the
protected void insert(int offset, ElementSpec[] data)
method (and where it makes sense)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20120621/47d7f52d/attachment.html>

More information about the swing-dev mailing list