299N/A/*
2362N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
299N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
299N/A *
299N/A * This code is free software; you can redistribute it and/or modify it
299N/A * under the terms of the GNU General Public License version 2 only, as
299N/A * published by the Free Software Foundation.
299N/A *
299N/A * This code is distributed in the hope that it will be useful, but WITHOUT
299N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
299N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
299N/A * version 2 for more details (a copy is included in the LICENSE file that
299N/A * accompanied this code).
299N/A *
299N/A * You should have received a copy of the GNU General Public License version
299N/A * 2 along with this work; if not, write to the Free Software Foundation,
299N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
299N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
299N/A */
299N/A
299N/Aimport java.awt.*;
299N/Aimport java.awt.print.*;
299N/Aimport javax.print.*;
299N/Aimport javax.print.attribute.*;
299N/A
299N/Apublic class PrintSE implements Printable {
299N/A
299N/A public static void main(String[] args) throws Exception {
299N/A GraphicsEnvironment.getLocalGraphicsEnvironment();
299N/A
299N/A PrintService service = PrintServiceLookup.lookupDefaultPrintService();
299N/A if (service == null) {
299N/A System.out.println("No print service found.");
299N/A return;
299N/A }
299N/A SimpleDoc doc =
299N/A new SimpleDoc(new PrintSE(),
299N/A DocFlavor.SERVICE_FORMATTED.PRINTABLE,
299N/A new HashDocAttributeSet());
299N/A DocPrintJob job = service.createPrintJob();
299N/A job.print(doc, new HashPrintRequestAttributeSet());
299N/A }
299N/A
299N/A public int print(Graphics g, PageFormat pf, int pg) {
299N/A if (pg > 0) return NO_SUCH_PAGE;
299N/A g.drawString("Test passes.", 100, 100);
299N/A return PAGE_EXISTS;
299N/A }
299N/A}