6051N/A/*
6051N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
6051N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6051N/A *
6051N/A * This code is free software; you can redistribute it and/or modify it
6051N/A * under the terms of the GNU General Public License version 2 only, as
6051N/A * published by the Free Software Foundation.
6051N/A *
6051N/A * This code is distributed in the hope that it will be useful, but WITHOUT
6051N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6051N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6051N/A * version 2 for more details (a copy is included in the LICENSE file that
6051N/A * accompanied this code).
6051N/A *
6051N/A * You should have received a copy of the GNU General Public License version
6051N/A * 2 along with this work; if not, write to the Free Software Foundation,
6051N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6051N/A *
6051N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6051N/A * or visit www.oracle.com if you need additional information or have any
6051N/A * questions.
6051N/A */
6051N/A
6051N/A/*
6051N/A * @test
6051N/A * @bug 8007458
6051N/A * @summary Tests GridBagLayout encoding
6051N/A * @author Sergey Malenkov
6051N/A */
6051N/A
6051N/Aimport java.awt.Component;
6051N/Aimport java.awt.GridBagConstraints;
6051N/Aimport java.awt.GridBagLayout;
6051N/Aimport java.lang.reflect.Field;
6051N/Aimport java.util.Hashtable;
6051N/Aimport java.util.Map;
6051N/Aimport javax.swing.JLabel;
6051N/A
6051N/Apublic final class java_awt_GridBagLayout extends AbstractTest<GridBagLayout> {
6051N/A private static final Field HASHTABLE = getField("java.awt.GridBagLayout.comptable");
6051N/A
6051N/A public static void main(String[] args) {
6051N/A new java_awt_GridBagLayout().test(true);
6051N/A }
6051N/A
6051N/A @Override
6051N/A protected GridBagLayout getObject() {
6051N/A GridBagLayout layout = new GridBagLayout();
6051N/A update(layout, "1", 1, 1);
6051N/A update(layout, "2", 2, 2);
6051N/A update(layout, "3", 3, 3);
6051N/A return layout;
6051N/A }
6051N/A
6051N/A @Override
6051N/A protected GridBagLayout getAnotherObject() {
6051N/A GridBagLayout layout = new GridBagLayout();
6051N/A update(layout, "11", 1, 1);
6051N/A update(layout, "12", 1, 2);
6051N/A update(layout, "21", 2, 1);
6051N/A update(layout, "22", 2, 2);
6051N/A return layout;
6051N/A }
6051N/A
6051N/A @Override
6051N/A protected void validate(GridBagLayout before, GridBagLayout after) {
6051N/A super.validate(before, after);
6051N/A try {
6051N/A Hashtable a = (Hashtable) HASHTABLE.get(after);
6051N/A Hashtable b = (Hashtable) HASHTABLE.get(before);
6051N/A super.validator.validate(a, b);
6051N/A
6051N/A// for (int i = 0; i < size; i++) {
6051N/A// validator.validate(NAME.get(a.get(i)), NAME.get(b.get(i)));
6051N/A// validator.validate(COMP.get(a.get(i)), COMP.get(b.get(i)));
6051N/A// }
6051N/A }
6051N/A catch (Exception exception) {
6051N/A throw new Error(exception);
6051N/A }
6051N/A
6051N/A
6051N/A
6051N/A// for (String name : names) {
6051N/A// validator.validate(getConstraints(before, name), getConstraints(after, name));
6051N/A// }
6051N/A }
6051N/A
6051N/A private static void update(GridBagLayout layout, String id, int x, int y) {
6051N/A GridBagConstraints gbc = new GridBagConstraints();
6051N/A gbc.gridx = x;
6051N/A gbc.gridy = y;
6051N/A layout.addLayoutComponent(new JLabel(id), gbc);
6051N/A }
6051N/A
6051N/A/*
6051N/A private static GridBagConstraints getConstraints(GridBagLayout layout, String id) {
6051N/A return (layout == null) ? null : ((MyGridBagLayout) layout).getConstraints(id);
6051N/A }
6051N/A*/
6051N/A}