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/EdgeTest/EdgeTest.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 4092755
27
* @summary Verifies that (0, 0) is the upper-left corner of the page, not
28
* the upper-left corner adjusted for the margins.
29
* @author dpm
30
* @run main/manual EdgeTest
31
*/
32
33
import java.awt.*;
34
import java.awt.event.*;
35
36
public class EdgeTest extends Panel {
37
public void init() {
38
Frame f = new Frame("EdgeTest");
39
f.setSize(50, 50);
40
f.addWindowListener( new WindowAdapter() {
41
public void windowClosing(WindowEvent ev) {
42
System.exit(0);
43
}
44
}
45
);
46
f.setVisible(true);
47
JobAttributes job = new JobAttributes();
48
job.setDialog(JobAttributes.DialogType.NONE);
49
PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", job, null);
50
if (pj != null) {
51
Graphics g = pj.getGraphics();
52
Dimension d = pj.getPageDimension();
53
g.setColor(Color.black);
54
g.setFont(new Font("Serif", Font.PLAIN, 12));
55
56
//top
57
g.drawLine(0, 0, d.width, 0);
58
59
//left
60
g.drawLine(0, 0, 0, d.height);
61
62
//bottom
63
g.drawLine(0, d.height, d.width, d.height);
64
65
//right
66
g.drawLine(d.width, 0, d.width, d.height);
67
68
g.drawString("This page should have no borders!",
69
d.width / 2 - 100, d.height / 2 - 10);
70
g.dispose();
71
pj.end();
72
}
73
}
74
75
public static void main(String[] args) {
76
new EdgeTest().init();
77
}
78
}
79
80