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