Java Clipboard Bug

Description

The usual system keys for using the system clipboard are disabled. Using Windows, you usually can use Ctrl-V, Ctrl-C and Ctrl-X without having to access the clipboard programmatically yourself. This is integrated behaviour. It is also the only method of transfering data from your clipboard to an applet if security restriction are in place which disallow using Toolkit.getSystemClipboard().

Affected systems

This bug has been observed on Windows 98 using the JRE 1.4.1_02 and even 1.4.2.-beta-b19, Windows XP is unaffected.

Solution

JRE 1.4.2 (build 1.4.2-b28) does not seem to be affected.

Testcase

Just try to copy any text and paste it into the applet. Alternatively, you can also try this applet directly from sun: http://java.sun.com/docs/books/tutorial/uiswing/events/DocumentEventDemo.html

This is the source:


import javax.swing.*;
import javax.swing.text.*;

public class ClipboardBugDemo extends JApplet {
    JTextField textField;
    public void init() {
        JLabel label = new JLabel("Paste with Ctrl-V, Copy with Ctrl-C, Cut with Ctrl-X");

        textField = new JTextField(20);

        JPanel panel = new JPanel();
        panel.add(textField);
        panel.add(label);
        setContentPane(panel);
    }
}

(sourcefile)

© 2003 Dirk Ahlers · dirk at dhere dot de