1.1 --- a/src/share/classes/javax/swing/plaf/basic/BasicTextUI.java Mon Mar 19 11:30:14 2012 +0100
1.2 +++ b/src/share/classes/javax/swing/plaf/basic/BasicTextUI.java Wed Apr 18 09:23:26 2012 +0200
1.3 @@ -31,6 +31,7 @@
1.4 import java.awt.im.InputContext;
1.5 import java.beans.*;
1.6 import java.io.*;
1.7 +import java.lang.ref.WeakReference;
1.8 import javax.swing.*;
1.9 import javax.swing.plaf.*;
1.10 import javax.swing.text.*;
1.11 @@ -2550,7 +2551,7 @@
1.12 TextTransferable(JTextComponent c, int start, int end) {
1.13 super(null, null);
1.14
1.15 - this.c = c;
1.16 + this.c = new WeakReference<>(c);
1.17
1.18 Document doc = c.getDocument();
1.19
1.20 @@ -2584,9 +2585,9 @@
1.21 }
1.22
1.23 void removeText() {
1.24 - if ((p0 != null) && (p1 != null) && (p0.getOffset() != p1.getOffset())) {
1.25 + if ((c!=null) && (p0 != null) && (p1 != null) && (p0.getOffset() != p1.getOffset())) {
1.26 try {
1.27 - Document doc = c.getDocument();
1.28 + Document doc = c.get().getDocument();
1.29 doc.remove(p0.getOffset(), p1.getOffset() - p0.getOffset());
1.30 } catch (BadLocationException e) {
1.31 }
1.32 @@ -2639,7 +2640,7 @@
1.33 Position p1;
1.34 String mimeType;
1.35 String richText;
1.36 - JTextComponent c;
1.37 + WeakReference<JTextComponent> c;
1.38 }
1.39
1.40 }