United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4644420 Uneditable JTextArea allows copy/paste via middle mouse button to occur
JDK-4644420 : Uneditable JTextArea allows copy/paste via middle mouse button to occur

Details
Type:
Bug
Submit Date:
2002-02-28
Status:
Resolved
Updated Date:
2002-12-11
Project Name:
JDK
Resolved Date:
2002-12-06
Component:
client-libs
OS:
solaris_9,solaris_8,solaris_2.6,linux,generic
Sub-Component:
javax.swing
CPU:
x86,sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0,1.4.1,1.4.1_03
Fixed Versions:
1.4.2 (b10)

Related Reports
Duplicate:
Duplicate:

Sub Tasks

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
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
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mantis-beta

FIXED IN:
mantis-beta

INTEGRATED IN:
mantis-b10
mantis-beta


                                     
2004-07-08



Hardware and Software, Engineered to Work Together