JDK-4513638 : cut/copy/drag broken for JEditorPane with RTFEditorKit
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-10-11
  • Updated: 2002-06-16
  • Resolved: 2002-04-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
1.4.1 hopperFixed
In merlin, cut/copy/drag are broken for JEditorPane when its EditorKit is an RTFEditorKit. Thus, setting the content-type to "text/rtf" or explicitly setting the EditorKit to an RTFEditorKit will prevent cut/copy/drag from working.

To see the problem, compile and run the following:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;

public class EditorPaneRTFTest extends JFrame {

    JEditorPane ep = new JEditorPane();

    public EditorPaneRTFTest() {
        setSize(500, 400);


        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((d.width - getWidth()) / 2, (d.height - getHeight()) / 2);
        try {
            ep.getDocument().insertString(0, "Try copying or moving this.", null);
        } catch (BadLocationException ble) {

        getContentPane().add(new JScrollPane(ep), BorderLayout.CENTER);

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                EditorPaneRTFTest test = new EditorPaneRTFTest();


Try copying the text (CTRL-C) - nothing is copied to the clipboard.
Try cutting the text (CTRL-X) - nothing is put on the clipboard and no text is removed.
Try dragging and dropping the text - the drag and drop completes and no text is transferred.

The expected result is that plain text should be moved/copied around.

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper VERIFIED IN: hopper-beta

EVALUATION This problem occurs because the RTFEditorKit.write() method always throws an IOException. When the TextTransferable defined in BasicTextUI sees this exception, it clears itself to represent an empty transfer. ###@###.### 2001-10-11 BasicTextUI has been changed so that it always exports "text/plain" using getSelectedText(). "text/plain" will also now always be imported using insertString(). This means that even when RTF fails to be exported through write as "text/rtf", "text/plain" will still be offered. This is how it used to be before this regression. ###@###.### 2002-04-04