HeadlessRectangle.java revision 10228:b2304c83a42d
1252310Shrs/*
2252310Shrs * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
3252310Shrs * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4252310Shrs *
5252310Shrs * This code is free software; you can redistribute it and/or modify it
6252310Shrs * under the terms of the GNU General Public License version 2 only, as
7252310Shrs * published by the Free Software Foundation.
8252310Shrs *
9252310Shrs * This code is distributed in the hope that it will be useful, but WITHOUT
10252310Shrs * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11252310Shrs * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12252310Shrs * version 2 for more details (a copy is included in the LICENSE file that
13298514Slme * accompanied this code).
14252310Shrs *
15252310Shrs * You should have received a copy of the GNU General Public License version
16252310Shrs * 2 along with this work; if not, write to the Free Software Foundation,
17252310Shrs * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18252310Shrs *
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 java.awt.*;
25
26/*
27 * @test
28 * @summary Check that Rectangle constructors and methods do not throw unexpected
29 *          exceptions in headless mode
30 * @run main/othervm -Djava.awt.headless=true HeadlessRectangle
31 */
32
33public class HeadlessRectangle {
34    public static void main(String args[]) {
35        Rectangle r;
36        r = new Rectangle();
37        r = new Rectangle(new Rectangle());
38        r = new Rectangle(100, 200);
39        r = new Rectangle(new Point(100, 200), new Dimension(300, 400));
40        r = new Rectangle(new Point(100, 200));
41        r = new Rectangle(new Dimension(300, 400));
42        r = new Rectangle(100, 200, 300, 400);
43        r.getX();
44        r.getY();
45        r.getWidth();
46        r.getHeight();
47        r.getBounds();
48        r.getBounds2D();
49        r.getLocation();
50        r.getSize();
51        r.contains(new Point(1, 2));
52        r.contains(1, 2);
53        r.contains(new Rectangle(1, 2, 3, 4));
54        r.contains(1, 2, 3, 4);
55        r.add(1, 2);
56        r.add(new Point(1, 2));
57        r.add(new Rectangle(1, 2, 3, 4));
58        r.grow(1, 2);
59        r.isEmpty();
60        r.toString();
61        r.hashCode();
62        r.getMinX();
63        r.getMinY();
64        r.getMaxX();
65        r.getMaxY();
66        r.getCenterX();
67        r.getCenterY();
68        r.getFrame();
69    }
70}
71