Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/List/ScrollOutside/ScrollOut.java
38828 views
/*1* Copyright (c) 2011, 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@bug 703673326@summary Regression : NullPointerException when scrolling horizontally on AWT List27@author Andrei Dmitriev area=awt-list28@library ../../regtesthelpers29@build Util30@run main ScrollOut31*/3233import java.awt.*;34import java.awt.event.*;35import test.java.awt.regtesthelpers.Util;3637public class ScrollOut38{39public static final void main(String args[])40{41final Frame frame = new Frame();42final List list = new List();43Robot robot = null;4445for (int i = 0; i < 5; i++){46list.add("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");47}4849frame.add(list);5051frame.pack();52frame.setLocationRelativeTo(null);53frame.setVisible(true);545556try{57robot = new Robot();58}catch(AWTException e){59throw new RuntimeException(e);60}61robot.waitForIdle();6263//Drag from center to the outside on left64Point from = new Point(list.getLocationOnScreen().x + list.getWidth()/2,65list.getLocationOnScreen().y + list.getHeight()/2);66Point to = new Point(list.getLocationOnScreen().x - 30,67from.y);6869robot.waitForIdle();70Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);7172robot.waitForIdle();7374//Drag from center to the outside on up75to = new Point(from.x,76list.getLocationOnScreen().y - 50);7778robot.waitForIdle();79Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);8081}//End init()82}838485