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