blob: ab8b19fc0415850ae5a68e5273078e555fee625c [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2001 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24import javax.print.*;
25import java.applet.*;
26import java.awt.*;
27
28public class Applet3 extends Applet {
29
30 String name = "Applet 3 ";
31 PrintService defServ = null;
32 PrintService[] allServices = null;
33 StreamPrintServiceFactory []fact = null;
34
35 public void init() {
36 PrintServiceLookup.registerService(new Applet3PrintService());
37 defServ = PrintServiceLookup.lookupDefaultPrintService();
38
39 allServices = PrintServiceLookup.lookupPrintServices(null,null);
40
41 fact = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
42 DocFlavor.SERVICE_FORMATTED.PRINTABLE,
43 DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
44
45 }
46
47 public void paint(Graphics g) {
48 g.drawString("This is " + name, 10, 20);
49 g.drawString("Default print service="+defServ,10,40);
50 g.drawString("Number of print services="+allServices.length,10,60);
51 g.drawString("Number of PS stream services="+fact.length,10,80);
52 int y=100;
53 for (int i=0;i<allServices.length;i++) {
54 if (allServices[i].getName().startsWith("Applet ")) {
55 g.drawString("Found service : "+allServices[i].getName(),10,y);
56 y+=20;
57 }
58 }
59 }
60
61 public static void main(String[] args) {
62 Applet3 applet = new Applet3();
63 applet.init();
64 Frame f = new Frame("Print Lookup Test");
65 f.add(applet);
66 f.setSize(300,200);
67 f.show();
68 }
69
70
71}