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

The JTextComponent.paste() method ignores current selection

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: ssR10000 Date: 11/20/2000



      The JTextComponent.paste() method ignores current selection.
      We found this problem since jdk1.4.0 beta b40. See example for more info.

      ---------------------- example ---------------------
      import javax.swing.text.*;
      import javax.swing.*;

      public class Test{

          public static void main(String argv[]) {
              try {
                  JTextComponent c = new JTextField(" Test text. This text should be ignored.");
                  int textLenght = c.getText().length();
                  c.setSelectionStart(5);
                  c.setSelectionEnd(10);
                  String selectedText = c.getSelectedText();
                  int clipboardLength = selectedText.length();

                  c.copy();
                  c.select( 0, 5);
                  System.out.println("Before paste() :" + c.getText());
                  c.paste();
                  System.out.println("After paste() :" + c.getText());

              } catch(SecurityException ace) {
                  System.out.println(ace);
              } catch(Throwable e) { System.out.println(e);}

          }
      }
      ---------------------- output ----------------------
      <ssw@sword(pts/21).281> java -fullversion
      java full version "1.4.0beta-b35"
      <ssw@sword(pts/21).282> java Test
      Before paste() : Test text. This text should be ignored.
      After paste() : text text. This text should be ignored.
      ---It's OK


      <ssw@sword(pts/21).284> java -fullversion
      java full version "1.4.0beta-b40"
      <ssw@sword(pts/21).285> java Test
      Before paste() : Test text. This text should be ignored.
      After paste() : Test text text. This text should be ignored.
      ---It's not OK
      ----------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            tprinzinsunw Timothy Prinzing (Inactive)
            Reporter:
            sswsunw Ssw Ssw (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: