1 /*
   2  * Copyright (c) 2011, 2016, 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   @key headful
  27   @bug 7036733
  28   @summary Regression : NullPointerException when scrolling horizontally on AWT List
  29   @author Andrei Dmitriev area=awt-list
  30   @library ../../regtesthelpers
  31   @build Util
  32   @run main ScrollOut
  33 */
  34 
  35 import java.awt.*;
  36 import java.awt.event.*;
  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 
  58         try{
  59             robot = new Robot();
  60         }catch(AWTException e){
  61             throw new RuntimeException(e);
  62         }
  63         robot.waitForIdle();
  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         robot.waitForIdle();
  72         Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
  73 
  74         robot.waitForIdle();
  75 
  76         //Drag from center to the outside on up
  77         to = new Point(from.x,
  78                        list.getLocationOnScreen().y - 50);
  79 
  80         robot.waitForIdle();
  81         Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
  82 
  83     }//End  init()
  84 }