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