United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4513638 : cut/copy/drag broken for JEditorPane with RTFEditorKit

Details
Type:
Bug
Submit Date:
2001-10-11
Status:
Closed
Updated Date:
2002-06-16
Project Name:
JDK
Resolved Date:
2002-04-27
Component:
client-libs
OS:
generic
Sub-Component:
javax.swing
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.1 (hopper)

Related Reports

Sub Tasks

Description
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() {
        setTitle("EditorPaneRTFTest");
        setSize(500, 400);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

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

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

}

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.

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
hopper

FIXED IN:
hopper

INTEGRATED IN:
hopper

VERIFIED IN:
hopper-beta


                                     
2004-06-14
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
                                     
2002-04-04



Hardware and Software, Engineered to Work Together