Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java
47626 views
/*1* Copyright (c) 2014, 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*/2223import java.awt.Color;24import java.awt.Dimension;25import java.awt.Point;26import java.awt.Robot;27import java.awt.event.ActionEvent;28import java.awt.event.ActionListener;29import javax.swing.BoxLayout;30import javax.swing.JComboBox;31import javax.swing.JFrame;32import test.java.awt.regtesthelpers.Util;333435/**36* AWT/Swing overlapping test for {@link javax.swing.JCombobox } component.37* <p>This test creates combobox and test if heavyweight component is drawn correctly then dropdown is shown.38* <p>See base class for details.39*/40/*41@test42@summary Overlapping test for javax.swing.JScrollPane43@author [email protected]: area=awt.mixing44@library ../../regtesthelpers45@build Util46@run main JComboBoxOverlapping47*/48public class JComboBoxOverlapping extends OverlappingTestBase {4950private boolean lwClicked = false;51private Point loc;52private Point loc2;5354{testEmbeddedFrame = true;}5556protected void prepareControls() {57final JFrame frame = new JFrame("Mixing : Dropdown Overlapping test");58frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));59frame.setSize(200, 200);60frame.setVisible(true);6162final JComboBox cb = new JComboBox(petStrings);63cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20));64cb.addActionListener(new ActionListener() {6566public void actionPerformed(ActionEvent e) {67if (e.getSource() == cb) {68lwClicked = true;69}70}71});7273frame.add(cb);74propagateAWTControls(frame);75frame.setVisible(true);76loc = cb.getLocationOnScreen();77loc2 = frame.getContentPane().getLocationOnScreen();78}7980@Override81protected boolean performTest() {82// run robot83Robot robot = Util.createRobot();84robot.setAutoDelay(ROBOT_DELAY);8586loc2.translate(75, 75);87pixelPreCheck(robot, loc2, currentAwtControl);8889loc.translate(3, 3);90clickAndBlink(robot, loc, false);9192clickAndBlink(robot, loc2, false);9394return lwClicked;95}9697// this strange plumbing stuff is required due to "Standard Test Machinery" in base class98public static void main(String args[]) throws InterruptedException {99instance = new JComboBoxOverlapping();100OverlappingTestBase.doMain(args);101}102}103104105