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