Path: blob/master/test/jdk/java/awt/Component/7097771/bug7097771.java
41152 views
/*1* Copyright (c) 2012, 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*/2223import test.java.awt.regtesthelpers.Util;2425import java.awt.AWTException;26import java.awt.Button;27import java.awt.Frame;28import java.awt.Robot;29import java.awt.event.ActionEvent;30import java.awt.event.ActionListener;3132/*33@test34@key headful35@bug 709777136@summary setEnabled does not work for components in disabled containers.37@author [email protected]: area=awt.component38@library ../../regtesthelpers39@build Util40@run main bug709777141*/42public final class bug7097771 extends Frame implements ActionListener {4344private static volatile boolean action;4546public static void main(final String[] args) throws AWTException {47final bug7097771 frame = new bug7097771();48frame.setSize(300, 300);49frame.setLocationRelativeTo(null);50final Button button = new Button();51button.addActionListener(frame);52frame.add(button);53frame.setVisible(true);54Robot robot = new Robot();55sleep(robot);56frame.setEnabled(false);57button.setEnabled(false);58button.setEnabled(true);59sleep(robot);60Util.clickOnComp(button, robot);61sleep(robot);62frame.dispose();63if (action) {64throw new RuntimeException("Button is not disabled.");65}66}6768@Override69public void actionPerformed(final ActionEvent e) {70action = true;71}7273private static void sleep(Robot robot) {74robot.waitForIdle();75try {76Thread.sleep(1000);77} catch (InterruptedException ignored) {78}79}80}818283