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