Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/PrintJob/EdgeTest/EdgeTest.java
38828 views
/*1* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 409275526* @summary Verifies that (0, 0) is the upper-left corner of the page, not27* the upper-left corner adjusted for the margins.28* @author dpm29* @run main/manual EdgeTest30*/3132import java.awt.*;33import java.awt.event.*;3435public class EdgeTest extends Panel {36public void init() {37Frame f = new Frame("EdgeTest");38f.setSize(50, 50);39f.addWindowListener( new WindowAdapter() {40public void windowClosing(WindowEvent ev) {41System.exit(0);42}43}44);45f.setVisible(true);46JobAttributes job = new JobAttributes();47job.setDialog(JobAttributes.DialogType.NONE);48PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", job, null);49if (pj != null) {50Graphics g = pj.getGraphics();51Dimension d = pj.getPageDimension();52g.setColor(Color.black);53g.setFont(new Font("Serif", Font.PLAIN, 12));5455//top56g.drawLine(0, 0, d.width, 0);5758//left59g.drawLine(0, 0, 0, d.height);6061//bottom62g.drawLine(0, d.height, d.width, d.height);6364//right65g.drawLine(d.width, 0, d.width, d.height);6667g.drawString("This page should have no borders!",68d.width / 2 - 100, d.height / 2 - 10);69g.dispose();70pj.end();71}72}7374public static void main(String[] args) {75new EdgeTest().init();76}77}787980