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

selections of TextArea are not correct

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1
    • client-libs
    • None
    • x86
    • windows_95



      Name: icT56964 Date: 06/02/97


      In Solaris, TextArea.getSelectionStart() returns 8, but in NT, it returns 10.
      It is a bug. (June2, icho@eng)
      ---------------------------------

      1.
      Try to compile and execute 2. program and type in displaied TextArea following text
      abc<RETURN>
      def<RETURN>
      and push "dump" button.
      I think TextArea's selections are 8,8, but it will be printed 10,10.
      I think it's not correct.

      2.
      import java.io.*;
      import java.awt.*;
      class test extends Frame {
          Button button = new Button("dump");
          TextArea textarea = new TextArea(12, 40);
          public test() {
              add("Center", textarea);
              add("South", button);
              pack();
          }
          public boolean action(Event event, Object arg) {
              if (event.target == button) {
                  try {
                      String text = textarea.getText();
                      int length = text.length();
                      System.out.println("length="+length);
                      System.out.print("text=");
                      for (int i = 0; i < length; i++) {
                          System.out.print(Integer.toHexString(text.charAt(i))+" ");
                      }
                      System.out.println("\nselection="+textarea.getSelectionStart()+","+textarea.getSelectionEnd());
                      return true;
                  } catch (Exception e) {
                  }
              }
              return false;
          }
          public static void main(String args[]) {
              new test().show();
         }
      }

      company - PFU Limited , email - ###@###.###
      ======================================================================

            ehawkessunw Eric Hawkes (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: