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