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