Path: blob/master/test/jdk/javax/swing/Headless/HeadlessJSplitPane.java
41149 views
/*1* Copyright (c) 2007, 2015, 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.getGraphicsConfiguration();109s.getTreeLock();110s.getToolkit();111s.isValid();112s.isDisplayable();113s.isVisible();114s.isShowing();115s.isEnabled();116s.enable(false);117s.enable(true);118s.enableInputMethods(false);119s.enableInputMethods(true);120s.show();121s.show(false);122s.show(true);123s.hide();124s.getForeground();125s.isForegroundSet();126s.getBackground();127s.isBackgroundSet();128s.getFont();129s.isFontSet();130Container c = new Container();131c.add(s);132s.getLocale();133for (Locale locale : Locale.getAvailableLocales())134s.setLocale(locale);135136s.getColorModel();137s.getLocation();138139boolean exceptions = false;140try {141s.getLocationOnScreen();142} catch (IllegalComponentStateException e) {143exceptions = true;144}145if (!exceptions)146throw new RuntimeException("IllegalComponentStateException did not occur when expected");147148s.location();149s.setLocation(1, 2);150s.move(1, 2);151s.setLocation(new Point(1, 2));152s.getSize();153s.size();154s.setSize(1, 32);155s.resize(1, 32);156s.setSize(new Dimension(1, 32));157s.resize(new Dimension(1, 32));158s.getBounds();159s.bounds();160s.setBounds(10, 10, 10, 10);161s.setBounds(new Rectangle(10, 10, 10, 10));162s.isLightweight();163s.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));164s.getCursor();165s.isCursorSet();166s.inside(1, 2);167s.contains(new Point(1, 2));168s.isFocusable();169s.setFocusable(true);170s.setFocusable(false);171s.transferFocus();172s.getFocusCycleRootAncestor();173s.nextFocus();174s.transferFocusUpCycle();175s.hasFocus();176s.isFocusOwner();177s.toString();178s.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);179s.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);180s.setComponentOrientation(ComponentOrientation.UNKNOWN);181s.getComponentOrientation();182}183}184185186