Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/Headless/HeadlessJLayeredPane.java
38840 views
/*1* Copyright (c) 2007, 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 javax.swing.*;24import java.awt.*;25import java.util.Locale;2627/*28* @test29* @summary Check that JLayeredPane constructor and methods do not throw unexpected30* exceptions in headless mode31* @run main/othervm -Djava.awt.headless=true HeadlessJLayeredPane32*/3334public class HeadlessJLayeredPane {35public static void main(String args[]) {36JLayeredPane lp = new JLayeredPane();37lp.getAccessibleContext();38lp.isFocusTraversable();39lp.setEnabled(false);40lp.setEnabled(true);41lp.requestFocus();42lp.requestFocusInWindow();43lp.getPreferredSize();44lp.getMaximumSize();45lp.getMinimumSize();46lp.contains(1, 2);47Component c1 = lp.add(new Component(){});48Component c2 = lp.add(new Component(){});49Component c3 = lp.add(new Component(){});50Insets ins = lp.getInsets();51lp.getAlignmentY();52lp.getAlignmentX();53lp.getGraphics();54lp.setVisible(false);55lp.setVisible(true);56lp.setForeground(Color.red);57lp.setBackground(Color.red);58for (String font : Toolkit.getDefaultToolkit().getFontList()) {59for (int j = 8; j < 17; j++) {60Font f1 = new Font(font, Font.PLAIN, j);61Font f2 = new Font(font, Font.BOLD, j);62Font f3 = new Font(font, Font.ITALIC, j);63Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j);6465lp.setFont(f1);66lp.setFont(f2);67lp.setFont(f3);68lp.setFont(f4);6970lp.getFontMetrics(f1);71lp.getFontMetrics(f2);72lp.getFontMetrics(f3);73lp.getFontMetrics(f4);74}75}76lp.enable();77lp.disable();78lp.reshape(10, 10, 10, 10);79lp.getBounds(new Rectangle(1, 1, 1, 1));80lp.getSize(new Dimension(1, 2));81lp.getLocation(new Point(1, 2));82lp.getX();83lp.getY();84lp.getWidth();85lp.getHeight();86lp.isOpaque();87lp.isValidateRoot();88lp.isOptimizedDrawingEnabled();89lp.isDoubleBuffered();90lp.getComponentCount();91lp.countComponents();92lp.getComponent(1);93lp.getComponent(2);94Component[] cs = lp.getComponents();95lp.getLayout();96lp.setLayout(new FlowLayout());97lp.doLayout();98lp.layout();99lp.invalidate();100lp.validate();101lp.remove(0);102lp.remove(c2);103lp.removeAll();104lp.preferredSize();105lp.minimumSize();106lp.getComponentAt(1, 2);107lp.locate(1, 2);108lp.getComponentAt(new Point(1, 2));109lp.isFocusCycleRoot(new Container());110lp.transferFocusBackward();111lp.setName("goober");112lp.getName();113lp.getParent();114lp.getPeer();115lp.getGraphicsConfiguration();116lp.getTreeLock();117lp.getToolkit();118lp.isValid();119lp.isDisplayable();120lp.isVisible();121lp.isShowing();122lp.isEnabled();123lp.enable(false);124lp.enable(true);125lp.enableInputMethods(false);126lp.enableInputMethods(true);127lp.show();128lp.show(false);129lp.show(true);130lp.hide();131lp.getForeground();132lp.isForegroundSet();133lp.getBackground();134lp.isBackgroundSet();135lp.getFont();136lp.isFontSet();137Container c = new Container();138c.add(lp);139lp.getLocale();140for (Locale locale : Locale.getAvailableLocales())141lp.setLocale(locale);142143lp.getColorModel();144lp.getLocation();145146boolean exceptions = false;147try {148lp.getLocationOnScreen();149} catch (IllegalComponentStateException e) {150exceptions = true;151}152if (!exceptions)153throw new RuntimeException("IllegalComponentStateException did not occur when expected");154155lp.location();156lp.setLocation(1, 2);157lp.move(1, 2);158lp.setLocation(new Point(1, 2));159lp.getSize();160lp.size();161lp.setSize(1, 32);162lp.resize(1, 32);163lp.setSize(new Dimension(1, 32));164lp.resize(new Dimension(1, 32));165lp.getBounds();166lp.bounds();167lp.setBounds(10, 10, 10, 10);168lp.setBounds(new Rectangle(10, 10, 10, 10));169lp.isLightweight();170lp.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));171lp.getCursor();172lp.isCursorSet();173lp.inside(1, 2);174lp.contains(new Point(1, 2));175lp.isFocusable();176lp.setFocusable(true);177lp.setFocusable(false);178lp.transferFocus();179lp.getFocusCycleRootAncestor();180lp.nextFocus();181lp.transferFocusUpCycle();182lp.hasFocus();183lp.isFocusOwner();184lp.toString();185lp.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);186lp.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);187lp.setComponentOrientation(ComponentOrientation.UNKNOWN);188lp.getComponentOrientation();189}190}191192193