HeadlessJSeparator.java revision 10228:b2304c83a42d
155714Skris/*
255714Skris * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
355714Skris * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
455714Skris *
555714Skris * This code is free software; you can redistribute it and/or modify it
655714Skris * under the terms of the GNU General Public License version 2 only, as
755714Skris * published by the Free Software Foundation.
8280297Sjkim *
955714Skris * This code is distributed in the hope that it will be useful, but WITHOUT
1055714Skris * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1155714Skris * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1255714Skris * version 2 for more details (a copy is included in the LICENSE file that
1355714Skris * accompanied this code).
1455714Skris *
15280297Sjkim * You should have received a copy of the GNU General Public License version
1655714Skris * 2 along with this work; if not, write to the Free Software Foundation,
1755714Skris * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1855714Skris *
1955714Skris * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2055714Skris * or visit www.oracle.com if you need additional information or have any
2155714Skris * questions.
22280297Sjkim */
2355714Skris
2455714Skrisimport javax.swing.*;
2555714Skrisimport java.awt.*;
2655714Skrisimport java.util.Locale;
2755714Skris
2855714Skris/*
2955714Skris * @test
3055714Skris * @summary Check that JSeparator constructor and methods do not throw unexpected
3155714Skris *          exceptions in headless mode
3255714Skris * @run main/othervm -Djava.awt.headless=true HeadlessJSeparator
3355714Skris */
3455714Skris
3555714Skrispublic class HeadlessJSeparator {
3655714Skris    public static void main(String args[]) {
37280297Sjkim        JSeparator sp = new JSeparator();
3855714Skris        sp.getAccessibleContext();
3955714Skris        sp.isFocusTraversable();
40280297Sjkim        sp.setEnabled(false);
4155714Skris        sp.setEnabled(true);
4255714Skris        sp.requestFocus();
4355714Skris        sp.requestFocusInWindow();
4455714Skris        sp.getPreferredSize();
4555714Skris        sp.getMaximumSize();
4655714Skris        sp.getMinimumSize();
4755714Skris        sp.contains(1, 2);
4855714Skris        Component c1 = sp.add(new Component(){});
4955714Skris        Component c2 = sp.add(new Component(){});
5055714Skris        Component c3 = sp.add(new Component(){});
5155714Skris        Insets ins = sp.getInsets();
52280297Sjkim        sp.getAlignmentY();
5355714Skris        sp.getAlignmentX();
5455714Skris        sp.getGraphics();
5555714Skris        sp.setVisible(false);
5655714Skris        sp.setVisible(true);
5755714Skris        sp.setForeground(Color.red);
5855714Skris        sp.setBackground(Color.red);
5955714Skris        for (String font : Toolkit.getDefaultToolkit().getFontList()) {
6055714Skris            for (int j = 8; j < 17; j++) {
6155714Skris                Font f1 = new Font(font, Font.PLAIN, j);
6255714Skris                Font f2 = new Font(font, Font.BOLD, j);
63238405Sjkim                Font f3 = new Font(font, Font.ITALIC, j);
64280297Sjkim                Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j);
65280297Sjkim
66280297Sjkim                sp.setFont(f1);
67280297Sjkim                sp.setFont(f2);
68280297Sjkim                sp.setFont(f3);
69280297Sjkim                sp.setFont(f4);
70280297Sjkim
71280297Sjkim                sp.getFontMetrics(f1);
72280297Sjkim                sp.getFontMetrics(f2);
7355714Skris                sp.getFontMetrics(f3);
74238405Sjkim                sp.getFontMetrics(f4);
75290207Sjkim            }
76290207Sjkim        }
7755714Skris        sp.enable();
78280297Sjkim        sp.disable();
79290207Sjkim        sp.reshape(10, 10, 10, 10);
80290207Sjkim        sp.getBounds(new Rectangle(1, 1, 1, 1));
81238405Sjkim        sp.getSize(new Dimension(1, 2));
82280297Sjkim        sp.getLocation(new Point(1, 2));
83290207Sjkim        sp.getX();
84290207Sjkim        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}
192