public void paste() {
		if (!isEditable())
			return;
		super.paste();
		if (clipboardText == null)
			return;
		if (!clipboardText.equals(getSystemClipboardText()))
			return; // this means that the text is from an external application
		unhighlightEmbedded();
		Transferable contents = clipboard.getContents(this);
		if (contents != null && contents.isDataFlavorSupported(StyledTextSelection.styledTextFlavor)) {
			StyledDocument s = null;
			try {
				s = (StyledDocument) contents.getTransferData(StyledTextSelection.styledTextFlavor);
			} catch (UnsupportedFlavorException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (s != null) {
				int pos = getCaretPosition() - s.getLength();
				ElementIterator i = new ElementIterator(s);
				Element e = i.next();
				while (e != null) {
					if (e instanceof AbstractDocument.LeafElement) {
						int m = e.getStartOffset();
						if (m >= s.getLength())
							break;
						int n = e.getEndOffset();
						AttributeSet a = e.getAttributes();
						Object name, attr;
						Component comp = null;
						Icon icon = null;
						for (Enumeration enum1 = a.getAttributeNames(); enum1.hasMoreElements();) {
							name = enum1.nextElement();
							attr = a.getAttribute(name);
							if (attr instanceof Icon) {
								icon = (Icon) attr;
							} else if (attr instanceof Component) {
								comp = (Component) attr;
							}
						}
						if (icon != null) {
							select(pos + m, pos + m + 1);
							insertDuplicatedIcon(icon);
							setCaretPosition(pos + s.getLength());
							// set the character attributes in case this image is hyperlinked
							getStyledDocument().setCharacterAttributes(pos + m, n - m, a, true);
						} else if (comp != null) {
							select(pos + m, pos + m + 1);
							pasteComponent(comp);
							setCaretPosition(pos + s.getLength());
						} else {
							getStyledDocument().setCharacterAttributes(pos + m, n - m, a, true);
						}
					}
					e = i.next();
				}
			}
		}
	}