1 /*
   2  * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   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 7036733
  27   @summary Regression : NullPointerException when scrolling horizontally on AWT List
  28   @author Andrei Dmitriev area=awt-list
  29   @library ../../regtesthelpers
  30   @build Util
  31   @run main ScrollOut
  32 */
  33 
  34 import java.awt.*;
  35 import java.awt.event.*;
  36 import sun.awt.SunToolkit;
  37 import test.java.awt.regtesthelpers.Util;
  38 
  39 public class ScrollOut
  40 {
  41     public static final void main(String args[])
  42     {
  43         final Frame frame = new Frame();
  44         final List list = new List();
  45         Robot robot = null;
  46 
  47         for (int i = 0; i < 5; i++){
  48             list.add("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
  49         }
  50 
  51         frame.add(list);
  52 
  53         frame.pack();
  54         frame.setLocationRelativeTo(null);
  55         frame.setVisible(true);
  56 
  57         ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
  58 
  59         try{
  60             robot = new Robot();
  61         }catch(AWTException e){
  62             throw new RuntimeException(e);
  63         }
  64 
  65         //Drag from center to the outside on left
  66         Point from = new Point(list.getLocationOnScreen().x + list.getWidth()/2,
  67                                list.getLocationOnScreen().y + list.getHeight()/2);
  68         Point to = new Point(list.getLocationOnScreen().x - 30,
  69                              from.y);
  70 
  71         ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
  72         Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
  73 
  74         ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
  75 
  76         //Drag from center to the outside on up
  77         to = new Point(from.x,
  78                        list.getLocationOnScreen().y - 50);
  79 
  80         ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
  81         Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
  82 
  83     }//End  init()
  84 }