JDK-4902837 : In a signed applet default cut/copy/paste using cntrl-x/cntrl-c/cntrl-v broken
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-08-07
  • Updated: 2004-02-20
  • Resolved: 2004-02-20
Description

Name: gm110360			Date: 08/07/2003


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Internet Explorer 6.0.28 SP1

A DESCRIPTION OF THE PROBLEM :
NOTE: This bug occurs only in 1.4.1_01 and above. Does not happen in 1.4.1 build 21. Can reproduce on 1.4.1_01 build 01 and 1.4.1_02 build 06.

All swing components in a "SIGNED" applet like JTextPane, JTextField, JTextArea etc does not allow cut/copy/ paste text from clipboard.

The default cut/copy/paste actions do not work. It works if the "Java plugin Console" is opened by default. This should be set to "Show Console" in the Windows Control Panel "Basic" tab. In this case the "Java Console" opens automatically as soon as the plugin is loaded. With this work around, the applet need not be signed to allow cut and paste, which itself is another bug.





STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
NOTE: This bug occurs only in 1.4.1_01 and above. Does not happen in 1.4.1 build 21. Can reproduce on 1.4.1_01 build 01 and 1.4.1_02 build 06.

1. Create an Applet class, with a JTextPane or JTextArea or JTextField.
2. In the start method verify that you have clipboad access.
3. Create a Jar file of this class.
4. Sign the applet.
5. Create a HTML to load this applet. ( I am using IE and Windows 2000)
6. Try copy and paste to and from clipboard from another text application like notepad.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In a signed applet, one has access to clipboard and cut/paste should work from a plain text source. It does not from 1.4.1.01 onwards. Works in 1.4.1.

ACTUAL -
Cut/paste/copy using Cntrl-x/Cntrl-v/Cntrl-v does not work.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/**
 *  Test Applet class to reproduce this bug.
 */

import java.applet.Applet;

import javax.swing.JTextPane;
import javax.swing.border.Border;

public class TestApplet extends Applet {

  JTextPane textPane;

  public TestApplet() {
  }

  public void start(){
    add(textPane);
   String text = null;
  try {
    checkForClipboardAccess();
     text = "Clipboard access has been verified. Try to copy into or from this using Cntrl-c / Cntrl-v from an external application. Make sure you have SIGNED the applet before trying. Make sure the java plug-in console is closed by default, i.e when the plug-in is loaded the console should not show up by default.";
  } catch (SecurityException se){
    text = "You do not have access to system clipboard. Make sure you have signed the applet.";
  }
    textPane.setText(text);
    Border border = javax.swing.BorderFactory.createLineBorder(java.awt.Color.black);
    textPane.setBorder(border);

  }

  public void stop(){
    remove(textPane);
    repaint();
  }

  public void init(){
    textPane = new JTextPane();
    setLayout(new java.awt.BorderLayout());
  }

  public void destroy(){
    textPane = null;
  }

  private void  checkForClipboardAccess(){
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      // try to see if we have clipboard access. If not this will throw an exception
      sm.checkSystemClipboardAccess();
    }
  }
}


-----------------------------------------------
HTML used for launching the applet
-----------------------------------------------

<html>
<head>
<title>Signed Applet Cut/Copy/Paste bug</title>

<!-- Code specific to this page -->
<script language="JavaScript">
<!--

// -->

</script>
</head>


<body>
<h1>Signed Applet Cut/Copy/Paste bug</h1>
    <hr>
<OBJECT classid = "clsid:CAFEEFAC-0014-0001-0002-ABCDEFFEDCBA" name="TestApplet" width="375" height="150" vspace="0" codebase = "http://java.sun.com/products/plugin/autodl/jinstall-1_4_1_02-windows-i586.cab#Version=1,4,1,2">
<PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4.1_02-b06">
<PARAM NAME="archive" VALUE="TestApplet.jar">
<PARAM NAME="code" VALUE="TestApplet.class">

</OBJECT>

</body>
</html>

------------------------------------------------------------------------
Used Verisign certificate to sign my applet, and Accepted the certificate when the applet is being loaded.
-------------------------------------------------------------------------
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
1. Handle Cntrl-x/Cntrl-v/Cntrl-c your self in each of your classes, that need cut/copy/paste.

OR
2. Ask each client to go to Control Panel. Change the default behaviour of the console to show by default. Now when the applet loads, the console opens automatically. It does not matter in this work around if the applet is signed or not signed.
(Incident Review ID: 186630) 
======================================================================

Comments
EVALUATION There are two problems reported in the description 1) Cut and paste doesn't work even when the applet is signed 2) If the Java console is up by default, cut and paste works always The second problem may be a duplicate of #4856343. Both the issues looks to be Swing related. Re-assigning to them for further evaluation ###@###.### 2003-11-05 Name: ik75403 Date: 02/20/2004 this bug will be fixed along with 4841767 closing as dup ======================================================================
05-11-2003