Path: blob/master/test/jdk/java/beans/XMLEncoder/java_awt_BorderLayout.java
41149 views
/*1* Copyright (c) 2008, 2013, 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 491685226* @summary Tests BorderLayout encoding27* @run main/othervm -Djava.security.manager=allow java_awt_BorderLayout28* @author Sergey Malenkov29*/3031import java.awt.BorderLayout;32import javax.swing.JLabel;3334public final class java_awt_BorderLayout extends AbstractTest<BorderLayout> {35private static final String[] CONSTRAINTS = {36BorderLayout.NORTH,37BorderLayout.SOUTH,38BorderLayout.EAST,39BorderLayout.WEST,40BorderLayout.CENTER,41BorderLayout.PAGE_START,42BorderLayout.PAGE_END,43BorderLayout.LINE_START,44BorderLayout.LINE_END,45};4647public static void main(String[] args) {48new java_awt_BorderLayout().test(true);49}5051@Override52protected BorderLayout getObject() {53BorderLayout layout = new BorderLayout();54update(layout, BorderLayout.EAST);55update(layout, BorderLayout.WEST);56update(layout, BorderLayout.NORTH);57update(layout, BorderLayout.SOUTH);58return layout;59}6061@Override62protected BorderLayout getAnotherObject() {63BorderLayout layout = getObject();64update(layout, BorderLayout.CENTER);65return layout;66}6768@Override69protected void validate(BorderLayout before, BorderLayout after) {70super.validate(before, after);71for (String constraint : CONSTRAINTS) {72super.validator.validate(before.getLayoutComponent(constraint),73after.getLayoutComponent(constraint));74}75}7677private static void update(BorderLayout layout, String constraints) {78layout.addLayoutComponent(new JLabel(constraints), constraints);79}80}818283