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