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

TextArea selection & deselection operations fail

XMLWordPrintable

    • Cause Known
    • other, x86
    • linux, solaris_2.5.1

      JDK VERSION
      OS: Linux
      DESCRIPTION:
      This test checks TextArea, with show() called before t.select().
      Text area selection & deselection fails. when the test is run with
      -Dawt.toolkit=sun.awt.motif.MToolkit option the test passes.
      It appears to be a problem with new xawt.
      STEPS TO REPRODUCE:
      1) set the path for Sun's jvm on the command prompt.
      2) Compile the java class - javac d622.java
      3) Run the java class - java d622
      4) Follow the instructions below:
      - When the window is first displayed, you should see "This is a line"
      displayed twice, and the "is" in the first "This" should be selected.
      - If you press 'a', then all the text should be selected
      - If you press 's', then "is" should be selected again
      - (Pressing MouseButton1 in the window should deselect the text)
      5) The test fails as it doesn't show the behaviour mentioned in the instructions above.
      6) Rerun the test with java -Dawt.toolkit=sun.awt.motif.MToolkit d622
      7) Follow the instructions as listed in 4. The test passes.
      TESTCASE:
      import java.io.*;
      import java.awt.*;
      import java.awt.event.KeyAdapter;
      import java.awt.event.KeyEvent;
      public class d622 extends Frame
      {
         TextArea t; // this contains the text
         d622()
         {
          super("setText test");
      t = new TextArea();
      t.addKeyListener(
      new KeyAdapter(){
      public void keyPressed(KeyEvent event)
      {
      if(event.getKeyChar()=='s')
      {
      t.select(2,5);

      }
      if(event.getKeyChar()=='a')
      {
      t.selectAll();

      }
      event.consume();
      }
      }
          );
          add("Center", t); // Frame uses BorderLayout
          setBounds(0,0,400,400); // makes ourselves a reasonable size
          for(int i=0;i<2;i++)
      t.append("This is a line \n");
          show();
          t.select(2,5);
          t.requestFocus();
      }
      public static void main(String args[])
      {
            d622 frame=new d622();
      }
      }
      ###@###.### 2005-07-15 15:48:24 GMT

            denis Denis Fokin (Inactive)
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: