Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4327122

Non-editable JTextArea allows copy and Paste using CTRL+C and CTRL +V

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      x86
    • OS:
      generic, windows_nt, windows_2000
    • Verification:
      Verified

      Description



      Name: jbT81659 Date: 04/02/2000

      Even if you set JTextArea to be non editable, it is possible to copy text from it and
      to paste text to it.
      To reproduce this bug:
      Note that the following code has the line area.setEditable(false);
      Compile and run the code.
      Select some text and use CTRL + C to copy it.
      Position the cursor somewhere in the JTextArea and Press CTRL +V.
      Note that text is pasted.

      ------Code----------

      /* Copyright (c) Sun Microsystems 1999

      $Header: /home/sun/src/JDK1.2/jTextArea.java,v 1.20 2000/03/30 14:59:14 isam Exp $

      */

      import java.awt.*;
      import java.awt.event.*;
      import java.awt.font.*;
      import javax.swing.*;
      import javax.swing.border.*;
      import javax.swing.text.*;

      public class jTextArea extends JApplet
      {
        public void init()
        {
          jTextArea1 jTextComponent2 = new jTextArea1();
          getContentPane().add(jTextComponent2);
        }

        public static void main(String[] args)
        {
          JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
          frame.setContentPane(new jTextArea1());
          frame.pack();
          frame.setVisible(true);
              frame.addWindowListener( new WindowAdapter()
              {
                   public void windowClosing( WindowEvent e)
                   {
                       System.exit(0);
                   }
              });
        }
      }
      class jTextArea1 extends JPanel
      {
        public jTextArea1()
        {
          JLabel l;
          JPanel p;
          JTextArea area;
          JTextPane pane;
          JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTA1");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          area = new JTextArea(10,30);
          area.setEditable(false);
          area.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
          area.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          area.setLineWrap(true);
          p.add(l);
          p.add(area);
          p.setPreferredSize(new Dimension(375,310));
          panel.add(p);

          panel.setPreferredSize(new Dimension(400,400));
          JScrollPane scroll = new JScrollPane(panel);
          scroll.setPreferredSize(new Dimension(420,450));

          add(scroll);
        }
      }



      WorkAround:
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            shickeysunw Shannon Hickey (Inactive)
            Reporter:
            jbenavrasunw Jonathan Benavraham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: