3448N/A/*
3909N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
3448N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3448N/A *
3448N/A * This code is free software; you can redistribute it and/or modify it
3448N/A * under the terms of the GNU General Public License version 2 only, as
3448N/A * published by the Free Software Foundation.
3448N/A *
3448N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3448N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3448N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3448N/A * version 2 for more details (a copy is included in the LICENSE file that
3448N/A * accompanied this code).
3448N/A *
3448N/A * You should have received a copy of the GNU General Public License version
3448N/A * 2 along with this work; if not, write to the Free Software Foundation,
3448N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3448N/A *
3448N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3448N/A * or visit www.oracle.com if you need additional information or have any
3448N/A * questions.
3448N/A */
3448N/A
544N/A/*
544N/A @test %I% %E%
544N/A @bug 2161766
544N/A @summary Component is missing after changing the z-order of the component & focus is not transfered in
544N/A @author Andrei Dmitriev : area=awt.container
544N/A @run main CheckZOrderChange
544N/A*/
544N/Aimport java.awt.*;
544N/Aimport java.awt.event.*;
544N/A
544N/Apublic class CheckZOrderChange {
544N/A
544N/A private static Button content[] = new Button[]{new Button("Button 1"), new Button("Button 2"), new Button("Button 3"), new Button("Button 4")};
544N/A private static Frame frame;
544N/A
544N/A public static void main(String[] args) {
544N/A
544N/A frame = new Frame("Test Frame");
544N/A frame.setLayout(new FlowLayout());
544N/A
544N/A for (Button b: content){
544N/A frame.add(b);
544N/A }
544N/A
544N/A frame.setSize(300, 300);
544N/A frame.setVisible(true);
544N/A
544N/A /* INITIAL ZORDERS ARE*/
544N/A for (Button b: content){
544N/A System.out.println("frame.getComponentZOrder("+ b +") = " + frame.getComponentZOrder(b));
544N/A }
544N/A
544N/A //Change the Z Order
544N/A frame.setComponentZOrder(content[0], 2);
544N/A System.out.println("ZOrder of button1 changed to 2");
544N/A
544N/A if (frame.getComponentZOrder(content[0]) != 2 ||
544N/A frame.getComponentZOrder(content[1]) != 0 ||
544N/A frame.getComponentZOrder(content[2]) != 1 ||
544N/A frame.getComponentZOrder(content[3]) != 3)
544N/A {
544N/A for (Button b: content){
544N/A System.out.println("frame.getComponentZOrder("+ b +") = " + frame.getComponentZOrder(b));
544N/A }
544N/A throw new RuntimeException("TEST FAILED: getComponentZOrder did not return the correct value");
544N/A }
544N/A }
544N/A}