public void copy() {
		if (getSelectedText() == null)
			return;
		StyledTextSelection contents = new StyledTextSelection();
		contents.clearText();
		int start = getSelectionStart();
		int end = getSelectionEnd();
		List<Element> leaves = getSelectedLeafElements();
		Document d = getDocument();
		if (leaves != null && !leaves.isEmpty()) {
			int i, j;
			String str = null;
			for (Element e : leaves) {
				i = Math.max(e.getStartOffset(), start);
				j = Math.min(e.getEndOffset(), end);
				try {
					str = d.getText(i, j - i);
					contents.insertString(i - start, str, e.getAttributes());
				} catch (BadLocationException ble) {
					ble.printStackTrace();
				}
			}
		}
		clipboard.setContents(contents, this);
		clipboardText = getSelectedText();
		super.copy();
	}