1 /* 2 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import javax.swing.*; 25 import java.awt.*; 26 import java.util.Locale; 27 28 /* 29 * @test 30 * @summary Check that JSeparator constructor and methods do not throw unexpected 31 * exceptions in headless mode 32 * @run main/othervm -Djava.awt.headless=true HeadlessJSeparator 33 */ 34 35 public class HeadlessJSeparator { 36 public static void main(String args[]) { 37 JSeparator sp = new JSeparator(); 38 sp.getAccessibleContext(); 39 sp.isFocusTraversable(); 40 sp.setEnabled(false); 41 sp.setEnabled(true); 42 sp.requestFocus(); 43 sp.requestFocusInWindow(); 44 sp.getPreferredSize(); 45 sp.getMaximumSize(); 46 sp.getMinimumSize(); 47 sp.contains(1, 2); 48 Component c1 = sp.add(new Component(){}); 49 Component c2 = sp.add(new Component(){}); 50 Component c3 = sp.add(new Component(){}); 51 Insets ins = sp.getInsets(); 52 sp.getAlignmentY(); 53 sp.getAlignmentX(); 54 sp.getGraphics(); 55 sp.setVisible(false); 56 sp.setVisible(true); 57 sp.setForeground(Color.red); 58 sp.setBackground(Color.red); 59 for (String font : Toolkit.getDefaultToolkit().getFontList()) { 60 for (int j = 8; j < 17; j++) { 61 Font f1 = new Font(font, Font.PLAIN, j); 62 Font f2 = new Font(font, Font.BOLD, j); 63 Font f3 = new Font(font, Font.ITALIC, j); 64 Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); 65 66 sp.setFont(f1); 67 sp.setFont(f2); 68 sp.setFont(f3); 69 sp.setFont(f4); 70 71 sp.getFontMetrics(f1); 72 sp.getFontMetrics(f2); 73 sp.getFontMetrics(f3); 74 sp.getFontMetrics(f4); 75 } 76 } 77 sp.enable(); 78 sp.disable(); 79 sp.reshape(10, 10, 10, 10); 80 sp.getBounds(new Rectangle(1, 1, 1, 1)); 81 sp.getSize(new Dimension(1, 2)); 82 sp.getLocation(new Point(1, 2)); 83 sp.getX(); 84 sp.getY(); 85 sp.getWidth(); 86 sp.getHeight(); 87 sp.isOpaque(); 88 sp.isValidateRoot(); 89 sp.isOptimizedDrawingEnabled(); 90 sp.isDoubleBuffered(); 91 sp.getComponentCount(); 92 sp.countComponents(); 93 sp.getComponent(1); 94 sp.getComponent(2); 95 Component[] cs = sp.getComponents(); 96 sp.getLayout(); 97 sp.setLayout(new FlowLayout()); 98 sp.doLayout(); 99 sp.layout(); 100 sp.invalidate(); 101 sp.validate(); 102 sp.remove(0); 103 sp.remove(c2); 104 sp.removeAll(); 105 sp.preferredSize(); 106 sp.minimumSize(); 107 sp.getComponentAt(1, 2); 108 sp.locate(1, 2); 109 sp.getComponentAt(new Point(1, 2)); 110 sp.isFocusCycleRoot(new Container()); 111 sp.transferFocusBackward(); 112 sp.setName("goober"); 113 sp.getName(); 114 sp.getParent(); 115 sp.getPeer(); 116 sp.getGraphicsConfiguration(); 117 sp.getTreeLock(); 118 sp.getToolkit(); 119 sp.isValid(); 120 sp.isDisplayable(); 121 sp.isVisible(); 122 sp.isShowing(); 123 sp.isEnabled(); 124 sp.enable(false); 125 sp.enable(true); 126 sp.enableInputMethods(false); 127 sp.enableInputMethods(true); 128 sp.show(); 129 sp.show(false); 130 sp.show(true); 131 sp.hide(); 132 sp.getForeground(); 133 sp.isForegroundSet(); 134 sp.getBackground(); 135 sp.isBackgroundSet(); 136 sp.getFont(); 137 sp.isFontSet(); 138 Container c = new Container(); 139 c.add(sp); 140 sp.getLocale(); 141 for (Locale locale : Locale.getAvailableLocales()) 142 sp.setLocale(locale); 143 144 sp.getColorModel(); 145 sp.getLocation(); 146 147 boolean exceptions = false; 148 try { 149 sp.getLocationOnScreen(); 150 } catch (IllegalComponentStateException e) { 151 exceptions = true; 152 } 153 if (!exceptions) 154 throw new RuntimeException("IllegalComponentStateException did not occur when expected"); 155 156 sp.location(); 157 sp.setLocation(1, 2); 158 sp.move(1, 2); 159 sp.setLocation(new Point(1, 2)); 160 sp.getSize(); 161 sp.size(); 162 sp.setSize(1, 32); 163 sp.resize(1, 32); 164 sp.setSize(new Dimension(1, 32)); 165 sp.resize(new Dimension(1, 32)); 166 sp.getBounds(); 167 sp.bounds(); 168 sp.setBounds(10, 10, 10, 10); 169 sp.setBounds(new Rectangle(10, 10, 10, 10)); 170 sp.isLightweight(); 171 sp.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); 172 sp.getCursor(); 173 sp.isCursorSet(); 174 sp.inside(1, 2); 175 sp.contains(new Point(1, 2)); 176 sp.isFocusable(); 177 sp.setFocusable(true); 178 sp.setFocusable(false); 179 sp.transferFocus(); 180 sp.getFocusCycleRootAncestor(); 181 sp.nextFocus(); 182 sp.transferFocusUpCycle(); 183 sp.hasFocus(); 184 sp.isFocusOwner(); 185 sp.toString(); 186 sp.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); 187 sp.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 188 sp.setComponentOrientation(ComponentOrientation.UNKNOWN); 189 sp.getComponentOrientation(); 190 } 191 }