Path: blob/master/test/jdk/java/awt/List/ScrollOutside/ScrollOut.java
41153 views
/*1* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24@test25@key headful26@bug 703673327@summary Regression : NullPointerException when scrolling horizontally on AWT List28@author Andrei Dmitriev area=awt-list29@library ../../regtesthelpers30@build Util31@run main ScrollOut32*/3334import java.awt.*;35import java.awt.event.*;36import test.java.awt.regtesthelpers.Util;3738public class ScrollOut39{40public static final void main(String args[])41{42final Frame frame = new Frame();43final List list = new List();44Robot robot = null;4546for (int i = 0; i < 5; i++){47list.add("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");48}4950frame.add(list);5152frame.pack();53frame.setLocationRelativeTo(null);54frame.setVisible(true);555657try{58robot = new Robot();59}catch(AWTException e){60throw new RuntimeException(e);61}62robot.waitForIdle();6364//Drag from center to the outside on left65Point from = new Point(list.getLocationOnScreen().x + list.getWidth()/2,66list.getLocationOnScreen().y + list.getHeight()/2);67Point to = new Point(list.getLocationOnScreen().x - 30,68from.y);6970robot.waitForIdle();71Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);7273robot.waitForIdle();7475//Drag from center to the outside on up76to = new Point(from.x,77list.getLocationOnScreen().y - 50);7879robot.waitForIdle();80Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);8182}//End init()83}848586