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