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