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