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