JDK-4648521 : Copy/Paste stops working after opening modal dialog
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-03-07
  • Updated: 2002-05-10
  • Resolved: 2002-05-10
Related Reports
Duplicate :  
Description
cp

Name: gm110360			Date: 03/06/2002


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

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]

ADDITIONAL OPERATING SYSTEMS :
not sure


EXTRA RELEVANT SYSTEM CONFIGURATION :
  Bug occurs on both IE 6 and IE5.5.  Haven't tested on others

A DESCRIPTION OF THE PROBLEM :
This bug involves copying and pasting from the os(windows)
into an applet.  We were getting reports of pasting stoping
working. After some testing, i found that it would quit
working entirely after a user opened a modal dialog box.
  From that point on, copy/paste would not work at all, until
the browser was completely shut down and brought back up.

Upon further investigation, i built a small sample applet
that did nothing but have a single textarea and a dialog
(with a textarea in it).  If i made it modal, it followed
the same bug, if i made it non-modal, i could copy and
paste all day.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Load index.html (which contains the applet)

The main applet screen has 2 parts, a combobox for
selecting modality, and a big text area.

2. Select false in the combo, meaning non-modal
3. Select another application, and copy some text.
4. Paste (ctrl-v) the text in the large textarea (all ok)
5. Right click in the textarea (this opens the dialog)
6. Resize it so you can see (sorry, i was lazy)
7. Paste the text in there (all ok)
8. Click ok or cancel
9. back on the main applet window, paste in the text area
(all ok)
10. repeat as much as you want.
11. Change the combo to true (modal)
12. right click in the textarea.
13. try to paste in the dialog's textarea
14. close the dialog.
15. try to paste in the applets textarea.



EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect the paste to work in both cases.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
-------------------------------------------------------------------------------
index.html
-------------------------------------------------------------------------------
<html><body style='margin:0px;border:0px'>
	<object name='ceui' width='100%' height='100%' classid='clsid:8AD9C840-
044E-11D1-B3E9-00805F499D93'
codebase='http://java.sun.com/products/plugin/1.4/jinstall-14-
win32.cab#Version=1,4,0,mn'>
		<param name='name' value='CEUI'>
		<param name='code' value='JSTestApplet.class'>
		<param name='codebase' value='./'>
		<param name='type' value='application/x-java-applet;jpi-
version=1.4'>
		<param name='mayscript' value='true'>
		<param name='scriptable' value='true'>
	</object>
</body></html>


--------------------------------------------------------------------------------
JSTestApplet.java
--------------------------------------------------------------------------------
/*
 * JSTestApplet.java
 *
 * Created on January 28, 2002, 4:25 PM
 */

import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/**
 * @author  ###@###.###
 */
public class JSTestApplet extends JApplet {

    private JComboBox modalCombo ;
    private RevolverTextAreaDialog textAreaDialog;
    
    public JSTestApplet()
    {
        //** set layout
        this.getContentPane().setLayout(new BorderLayout());
    }

    public void init () {
        Vector victor = new Vector();
        victor.add("true");
        victor.add("false");
        
        modalCombo = new JComboBox(victor);
        
        this.getContentPane().add(modalCombo,BorderLayout.NORTH);
        
        JTextArea fakecell = new JTextArea();
        fakecell.addMouseListener(new cellTextAreMouseListener());
        this.getContentPane().add(fakecell,BorderLayout.CENTER);
    }

    private void rightClickedCellTextArea(Component targetComponent)
    {
        JTextArea curTextArea = (JTextArea)targetComponent;
        String currentValue = curTextArea.getText();
        
        final Window appletParentWindow = (java.awt.Window)
javax.swing.SwingUtilities.getAncestorOfClass(java.awt.Window.class, this);
        final Frame appletFrame = appletParentWindow instanceof Frame?((Frame)
appletParentWindow):(new Frame());
        
        boolean modal = ((String)this.modalCombo.getSelectedItem()).equals
("true")?true:false;
        
        textAreaDialog = new RevolverTextAreaDialog(appletFrame, curTextArea,
modal);
        textAreaDialog.show();
    }
    
/////////////INTERNAL CLASSES
        class cellTextAreMouseListener implements MouseListener
        {
            public void mouseExited(java.awt.event.MouseEvent mouseEvent) {
            }
            public void mouseReleased(java.awt.event.MouseEvent mouseEvent) {
                if(mouseEvent.isPopupTrigger())
                {
                    rightClickedCellTextArea(mouseEvent.getComponent());
                }
            }
            public void mousePressed(java.awt.event.MouseEvent mouseEvent) {
            }
            public void mouseClicked(java.awt.event.MouseEvent mouseEvent) {
            }
            public void mouseEntered(java.awt.event.MouseEvent mouseEvent) {
             }
        }
    
        class RevolverTextAreaDialog extends JDialog
        {
            private JButton okButton;
            private JButton cancelButton;
            private JTextArea talkBackComponent;
            private JTextArea revolverTextArea;
            
            public RevolverTextAreaDialog(Frame aFrame,JTextArea tBC, boolean
modal) {
               
                super(aFrame, modal);
                
                this.talkBackComponent = tBC;
                revolverTextArea = new JTextArea();
                this.getContentPane().add(revolverTextArea,
BorderLayout.CENTER);
                okButton = new JButton("OK");
                cancelButton = new JButton("Cancel");
                JPanel buttons = new JPanel();
                buttons.add(okButton);
                buttons.add(cancelButton);
                this.getContentPane().add(buttons, BorderLayout.SOUTH);
                okButton.addActionListener(new ActionListener(){
                    public void actionPerformed(java.awt.event.ActionEvent e)
                    {
                        okClickedInRevolverTextAreaDialog();
                    }
                });
                cancelButton.addActionListener(new ActionListener(){
                    public void actionPerformed(java.awt.event.ActionEvent e)
                    {
                        cancelClickedInRevolverTextAreaDialog();
                    }
                });
                
                this.pack();
            }
            public void okClickedInRevolverTextAreaDialog()
            {
                this.talkBackComponent.setText(this.revolverTextArea.getText());
                //closeCellEditors(true);
                this.dispose();
            }
            public void cancelClickedInRevolverTextAreaDialog()
            {
                this.dispose();
            }
        }
        //end of internal calss
}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Basically, we had to not use modal dialogs.
(Review ID: 143685) 
======================================================================

Comments
EVALUATION The described behavior happens in 1.3.1_02. In appletviewer (version 1.3.x), plugin 1.4.0, 1.4.1 and appletviewer 1.4.0 and 1.4.1 paste does not work at all (with or without opening of modal dialog) if copying (ctrl+C) was done in some other application (notepad, wordpad, etc). If copying was done inside applet (that's running in appletviewer or browser) then paste works. This is a security issue. If we create a policy file with policytool and grant all permissions to applets - copying from any application to system's clipboard and pasting to the applet's area (JTextArea for example) works fine. The decision if this is desired behavior or not should be made on appletviewer's level. Plug-in duplicates appletviewer's behavior. I found similar bug filed agains appletviewer. Closing this bug as a duplicate of 4668508 ###@###.### 2002-05-10
10-05-2002