|
| 1 | +/* |
| 2 | + * Copyright (c) 2004, 2025, 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 50510568367702 |
| 27 | + @key headful printer |
| 28 | + @summary PrintJob.getGraphics() should return null after PrintJob.end() is called. |
| 29 | + @run main GetGraphicsTest |
| 30 | +*/ |
| 31 | + |
| 32 | +import java.awt.Frame; |
| 33 | +import java.awt.Graphics; |
| 34 | +import java.awt.JobAttributes; |
| 35 | +import java.awt.PageAttributes; |
| 36 | +import java.awt.PrintJob; |
| 37 | +import java.awt.Toolkit; |
| 38 | + |
| 39 | +public class GetGraphicsTest { |
| 40 | + |
| 41 | + public static void main(String[] args) { |
| 42 | + |
| 43 | + JobAttributes ja = new JobAttributes(); |
| 44 | + ja.setDialog(JobAttributes.DialogType.NONE); |
| 45 | + PageAttributes pa = new PageAttributes(); |
| 46 | + pa.setOrigin( PageAttributes.OriginType.PRINTABLE); |
| 47 | + |
| 48 | + Toolkit tk = Toolkit.getDefaultToolkit(); |
| 49 | + PrintJob pjob = tk.getPrintJob(new Frame(),"Printing Test", ja,pa); |
| 50 | + if (pjob != null) { |
| 51 | + pjob.end(); |
| 52 | + Graphics pg = pjob.getGraphics(); |
| 53 | + if (pg == null) { |
| 54 | + System.out.println("Graphics is null, TEST PASSES"); |
| 55 | + } |
| 56 | + else { |
| 57 | + throw new RuntimeException("Graphics is NOT null, TEST FAILED"); |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments