Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/PrintJob/RoundedRectTest/RoundedRectTest.java
38828 views
1
/*
2
* Copyright (c) 1998, 2007, 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
/**
25
* @test
26
* @bug 4061440
27
* @summary Checks that rounded rectangles print correctly.
28
* @author dpm
29
*/
30
31
import java.awt.*;
32
import java.awt.event.*;
33
34
public class RoundedRectTest {
35
public static void main(String[] args) {
36
new RoundedRectTest().start();
37
}
38
public void start() {
39
new RoundedRectTestFrame();
40
}
41
}
42
43
class RoundedRectTestFrame extends Frame implements ActionListener {
44
PrintCanvas canvas;
45
46
public RoundedRectTestFrame () {
47
super("RoundedRectTest");
48
canvas = new PrintCanvas ();
49
add("Center", canvas);
50
51
Button b = new Button("Print");
52
b.setActionCommand ("print");
53
b.addActionListener (this);
54
add("South", b);
55
56
pack();
57
setVisible(true);
58
}
59
60
61
public void actionPerformed(ActionEvent e) {
62
String cmd = e.getActionCommand();
63
if (cmd.equals("print")) {
64
PrintJob pjob = getToolkit().getPrintJob(this, "RoundedRectTest",
65
null);
66
if (pjob != null) {
67
Graphics pg = pjob.getGraphics();
68
69
if (pg != null) {
70
canvas.printAll(pg);
71
pg.dispose(); //flush page
72
}
73
74
pjob.end();
75
}
76
}
77
}
78
}
79
80
class PrintCanvas extends Canvas {
81
public Dimension getPreferredSize() {
82
return new Dimension(659, 792);
83
}
84
85
public void paint (Graphics g) {
86
setBackground(Color.white);
87
g.setColor(Color.blue);
88
g.fillRoundRect(50, 50, 100, 200, 50, 50);
89
g.fillRoundRect(200, 50, 100, 100, 50, 50);
90
g.fillRoundRect(350, 50, 200, 100, 50, 50);
91
92
g.fillRoundRect(50, 300, 100, 200, 41, 97);
93
g.fillRoundRect(200, 300, 100, 100, 41, 97);
94
g.fillRoundRect(350, 300, 200, 100, 41, 97);
95
96
g.fillRoundRect(50, 550, 100, 200, 97, 41);
97
g.fillRoundRect(200, 550, 100, 100, 97, 41);
98
g.fillRoundRect(350, 550, 200, 100, 97, 41);
99
}
100
}
101
102