JDK-4644420 : Uneditable JTextArea allows copy/paste via middle mouse button to occur
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,1.4.1,1.4.1_03
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    generic,linux,solaris_2.6,solaris_8,solaris_9 generic,linux,solaris_2.6,solaris_8,solaris_9
  • CPU: generic,x86,sparc
  • Submitted: 2002-02-28
  • Updated: 2002-12-11
  • Resolved: 2002-12-06
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.
Other
1.4.2 b10Fixed
Related Reports
Duplicate :  
Duplicate :  
Description

Name: jk109818			Date: 02/27/2002


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


FULL OPERATING SYSTEM VERSION : Sun OS 5.8


ADDITIONAL OPERATING SYSTEMS : Linux



EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested on Sun Rays as well an Linux windowing environments.

A DESCRIPTION OF THE PROBLEM :
On Solaris/CDE and Linux/KDE, and probably all other X
windowing systems, copy paste is accomplished with selecting
text to be copied with the left mouse button and pasting
with center mouse. This method of copy paste still works on
JTextAreas even after they are set "uneditable". No other
method of inserting text that I know of allows text
insertion when the area is set uneditable.






STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Copy the code, below, compile and run.
2. Attempt to paste using one click method.
3. Press button to see pasted text output to console.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
 The paste should not work on an uneditable text area.

Actual:
 The one click paste succeeds on the uneditable area.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
//Here is a small sample program to duplicate this bug. The button which outputs
//the area's contents to the screen provides proof that the text has been
//inserted.

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

public class JTest {
  
  JTextArea jt;
  JFrame frame;

  public JTest() {
    frame = new JFrame("JTextArea Bug");
    jt = new JTextArea(10,7);
    jt.setEditable(false);
    JButton button = new JButton("output to stout");
    button.addActionListener( new ActionListener() {
	public void actionPerformed(ActionEvent e) {
	  System.out.println(jt.getText());
	}
      });
    Box box = new Box(BoxLayout.Y_AXIS);
    box.add(jt);
    box.add(button);
    frame.getContentPane().add(box);
    frame.pack();
    frame.setVisible(true);
  }
  
  public static void main(String[] args) {
    new JTest();
  }

}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
None known to me
(Review ID: 143474) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis-beta FIXED IN: mantis-beta INTEGRATED IN: mantis-b10 mantis-beta
2004-07-08

EVALUATION DefaultCaret.mouseClicked should check if the component's TransferHandler canImport() before calling importData(). ###@###.### 2002-05-02 DefaultCaret.mouseClicked will simply check to make sure that the component is both enabled and editable before calling importData(). ###@###.### 2002-11-20
2002-05-02