Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/print/applet/applet4/Applet4.java
38853 views
1
/*
2
* Copyright (c) 2001, 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
import javax.print.*;
25
import java.applet.*;
26
import java.awt.*;
27
28
public class Applet4 extends Applet {
29
30
String name = "Applet 4 ";
31
PrintService defServ = null;
32
PrintService[] allServices = null;
33
StreamPrintServiceFactory []fact = null;
34
35
public void init() {
36
PrintServiceLookup psl = new Applet4PrintServiceLookup();
37
PrintServiceLookup.registerServiceProvider(psl);
38
defServ = PrintServiceLookup.lookupDefaultPrintService();
39
40
allServices = PrintServiceLookup.lookupPrintServices(null,null);
41
42
fact = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
43
DocFlavor.SERVICE_FORMATTED.PRINTABLE,
44
DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
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] instanceof Applet4PrintService ||
55
allServices[i].getName().startsWith("Applet ")) {
56
g.drawString("Found service : "+allServices[i].getName(),10,y);
57
y+=20;
58
}
59
}
60
}
61
62
public static void main(String[] args) {
63
Applet4 applet = new Applet4();
64
applet.init();
65
Frame f = new Frame("Print Lookup Test");
66
f.add(applet);
67
f.setSize(300,200);
68
f.show();
69
}
70
71
72
}
73
74