< prev index next >

test/java/awt/TextField/ScrollSelectionTest/ScrollSelectionTest.java

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25   test
  26   @bug 4118621
  27   @summary tests that selected text isn't scrolled when there is enough room.
  28   @author prs: area=TextField
  29   @run applet/manual=yesno ScrollSelectionTest.html
  30 */
  31 
  32 /**
  33  * ScrollSelectionTest.java
  34  *
  35  * summary: tests that selected text isn't scrolled when there is enough room.
  36  */
  37 
  38 import java.applet.Applet;
  39 import java.awt.Dialog;
  40 import java.awt.Frame;
  41 import java.awt.TextField;
  42 import java.awt.TextArea;

  43 
  44 public class ScrollSelectionTest extends Applet
  45  {
  46 
  47    Frame frame = new Frame("ScrollSelectionTest frame");
  48    TextField tf = new TextField(40);
  49 
  50    public void init()
  51     {
  52       tf.setText("abcdefghijklmnopqrstuvwxyz");
  53       frame.add(tf);

  54       tf.select(0, 20);
  55 
  56       String[] instructions = {
  57           "INSTRUCTIONS:",

  58           "This is a test for a win32 specific problem",
  59          "If you see all the letters from 'a' to 'z' and",
  60           "letters from 'a' to 't' are selected then test passes.",
  61           "You may have to activate the frame to see the selection"
  62           + " highlighted (e.g. by clicking on frame's title)."






  63       };
  64       Sysout.createDialogWithInstructions( instructions );
  65 
  66     }// init()
  67 
  68    public void start ()
  69     {
  70       setSize (300,300);
  71       setVisible(true);
  72 
  73       frame.setVisible(true);
  74       frame.setBounds (400, 0, 300, 300);
  75 
  76     }// start()
  77 
  78  }// class ScrollSelectionTest
  79 
  80 /****************************************************
  81  Standard Test Machinery
  82  DO NOT modify anything below -- it's a standard
  83   chunk of code whose purpose is to make user
  84   interaction uniform, and thereby make it simpler
  85   to read and understand someone else's test.
  86  ****************************************************/
  87 
  88 /**
  89  This is part of the standard test machinery.
  90  It creates a dialog (with the instructions), and is the interface
  91   for sending text messages to the user.
  92  To print the instructions, send an array of strings to Sysout.createDialog
  93   WithInstructions method.  Put one line of instructions per array entry.
  94  To display a message for the tester to see, simply call Sysout.println




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25   test
  26   @bug 4118621 8149636
  27   @summary Test the selection scrolling in TextField.

  28   @run applet/manual=yesno ScrollSelectionTest.html
  29 */
  30 






  31 import java.applet.Applet;
  32 import java.awt.Dialog;
  33 import java.awt.Frame;
  34 import java.awt.TextField;
  35 import java.awt.TextArea;
  36 import java.awt.FlowLayout;
  37 
  38 public class ScrollSelectionTest extends Applet
  39  {
  40 
  41    Frame frame = new Frame("ScrollSelectionTest frame");
  42    TextField tf = new TextField(40);
  43 
  44    public void init()
  45     {
  46       tf.setText("abcdefghijklmnopqrstuvwxyz");
  47       frame.add(tf);
  48       frame.setLayout(new FlowLayout());
  49       tf.select(0, 20);
  50 
  51       String[] instructions = {
  52           "INSTRUCTIONS: There are 2 Tests",
  53           "Test1: Text visibility with Scroll",
  54           "This is a test for a win32 specific problem",
  55           "If you see all the letters from 'a' to 'z' and",
  56           "letters from 'a' to 't' are selected then test passes.",
  57           "You may have to activate the frame to see the selection",
  58           "highlighted (e.g. by clicking on frame's title).",
  59           ".",
  60           "Test2: Flicker with selection scroll",
  61           "Mouse press on the TextField text.",
  62           "Move mouse towards left or right with selecting text.",
  63           "Move mouse away outside the bounds of TextField.",
  64           "No flicker should be observed.",
  65       };
  66       Sysout.createDialogWithInstructions( instructions );
  67 
  68     }// init()
  69 
  70    public void start ()
  71     {
  72       setSize (300, 500);
  73       setVisible(true);
  74 
  75       frame.setVisible(true);
  76       frame.setBounds (400, 0, 400, 300);
  77 
  78     }// start()
  79 
  80  }// class ScrollSelectionTest
  81 
  82 /****************************************************
  83  Standard Test Machinery
  84  DO NOT modify anything below -- it's a standard
  85   chunk of code whose purpose is to make user
  86   interaction uniform, and thereby make it simpler
  87   to read and understand someone else's test.
  88  ****************************************************/
  89 
  90 /**
  91  This is part of the standard test machinery.
  92  It creates a dialog (with the instructions), and is the interface
  93   for sending text messages to the user.
  94  To print the instructions, send an array of strings to Sysout.createDialog
  95   WithInstructions method.  Put one line of instructions per array entry.
  96  To display a message for the tester to see, simply call Sysout.println


< prev index next >