author | psadhukhan |
Fri, 17 Jun 2016 16:52:38 +0530 | |
changeset 39520 | df99c6e834bc |
child 39849 | 2122a528e341 |
permissions | -rw-r--r-- |
39520
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
1 |
/* |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
4 |
* |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
8 |
* |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
13 |
* accompanied this code). |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
14 |
* |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
18 |
* |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
21 |
* questions. |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
22 |
*/ |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
23 |
/* |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
24 |
* @test |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
25 |
* @bug 6966350 |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
26 |
* @summary Verifies if Empty pages are printed on Lexmark E352dn PS3 |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
27 |
* with "1200 IQ" setting |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
28 |
* @run main/manual PrintTestLexmarkIQ |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
29 |
*/ |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
30 |
import java.awt.BorderLayout; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
31 |
import java.awt.Color; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
32 |
import java.awt.FlowLayout; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
33 |
import java.awt.Font; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
34 |
import java.awt.Graphics; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
35 |
import java.awt.Graphics2D; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
36 |
import java.awt.geom.Rectangle2D; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
37 |
import java.awt.print.PageFormat; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
38 |
import java.awt.print.Paper; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
39 |
import java.awt.print.Printable; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
40 |
import static java.awt.print.Printable.NO_SUCH_PAGE; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
41 |
import static java.awt.print.Printable.PAGE_EXISTS; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
42 |
import java.awt.print.PrinterException; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
43 |
import java.awt.print.PrinterJob; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
44 |
import javax.swing.JButton; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
45 |
import javax.swing.JDialog; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
46 |
import javax.swing.JPanel; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
47 |
import javax.swing.JTextArea; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
48 |
import javax.swing.SwingUtilities; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
49 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
50 |
public class PrintTestLexmarkIQ implements Printable { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
51 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
52 |
private static Thread mainThread; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
53 |
private static boolean testPassed; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
54 |
private static boolean testGeneratedInterrupt; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
55 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
56 |
public static void main(String[] args) throws Exception { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
57 |
SwingUtilities.invokeAndWait(() -> { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
58 |
doTest(PrintTestLexmarkIQ::printTest); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
59 |
}); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
60 |
mainThread = Thread.currentThread(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
61 |
try { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
62 |
Thread.sleep(90000); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
63 |
} catch (InterruptedException e) { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
64 |
if (!testPassed && testGeneratedInterrupt) { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
65 |
throw new RuntimeException(" Empty pages printed "); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
66 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
67 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
68 |
if (!testGeneratedInterrupt) { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
69 |
throw new RuntimeException("user has not executed the test"); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
70 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
71 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
72 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
73 |
private static void printTest() { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
74 |
PrinterJob pj = PrinterJob.getPrinterJob(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
75 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
76 |
PageFormat pf = pj.defaultPage(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
77 |
Paper paper = new Paper(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
78 |
double margin = 36; // half inch |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
79 |
paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2, |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
80 |
paper.getHeight() - margin * 2); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
81 |
pf.setPaper(paper); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
82 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
83 |
pj.setPrintable(new PrintTestLexmarkIQ(), pf); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
84 |
if (pj.printDialog()) { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
85 |
try { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
86 |
pj.print(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
87 |
} catch (PrinterException e) { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
88 |
System.out.println(e); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
89 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
90 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
91 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
92 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
93 |
public static synchronized void pass() { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
94 |
testPassed = true; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
95 |
testGeneratedInterrupt = true; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
96 |
mainThread.interrupt(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
97 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
98 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
99 |
public static synchronized void fail() { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
100 |
testPassed = false; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
101 |
testGeneratedInterrupt = true; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
102 |
mainThread.interrupt(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
103 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
104 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
105 |
private static void doTest(Runnable action) { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
106 |
String description |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
107 |
= " Install Lexmark E352dn PS3 or Dell 5310n printer.\n" |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
108 |
+ " A print dialog will be shown.\n" |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
109 |
+ " Select Normal 1200IQ setting in Properties->PrintQuality in Dell 5310n \n" |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
110 |
+ " or for Lexmark E352dn printer, select Normal 1200IQ setting in\n " |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
111 |
+ " Properties -> Advanced -> Graphic -> Print Quality.\n" |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
112 |
+ " Press Print. Verify the print output.\n " |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
113 |
+ " If empty page is printed, press Fail else press Pass."; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
114 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
115 |
final JDialog dialog = new JDialog(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
116 |
dialog.setTitle("1200IQTest"); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
117 |
JTextArea textArea = new JTextArea(description); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
118 |
textArea.setEditable(false); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
119 |
final JButton testButton = new JButton("Start Test"); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
120 |
final JButton passButton = new JButton("PASS"); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
121 |
passButton.setEnabled(false); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
122 |
passButton.addActionListener((e) -> { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
123 |
dialog.dispose(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
124 |
pass(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
125 |
}); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
126 |
final JButton failButton = new JButton("FAIL"); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
127 |
failButton.setEnabled(false); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
128 |
failButton.addActionListener((e) -> { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
129 |
dialog.dispose(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
130 |
fail(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
131 |
}); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
132 |
testButton.addActionListener((e) -> { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
133 |
testButton.setEnabled(false); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
134 |
action.run(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
135 |
passButton.setEnabled(true); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
136 |
failButton.setEnabled(true); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
137 |
}); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
138 |
JPanel mainPanel = new JPanel(new BorderLayout()); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
139 |
mainPanel.add(textArea, BorderLayout.CENTER); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
140 |
JPanel buttonPanel = new JPanel(new FlowLayout()); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
141 |
buttonPanel.add(testButton); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
142 |
buttonPanel.add(passButton); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
143 |
buttonPanel.add(failButton); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
144 |
mainPanel.add(buttonPanel, BorderLayout.SOUTH); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
145 |
dialog.add(mainPanel); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
146 |
dialog.pack(); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
147 |
dialog.setVisible(true); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
148 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
149 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
150 |
public int print(Graphics g, PageFormat pf, int pi) |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
151 |
throws PrinterException { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
152 |
if (pi != 0) { |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
153 |
return NO_SUCH_PAGE; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
154 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
155 |
Graphics2D g2 = (Graphics2D) g; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
156 |
g2.setFont(new Font("Serif", Font.PLAIN, 36)); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
157 |
g2.setPaint(Color.black); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
158 |
g2.drawString("Java Source and Support", 100, 100); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
159 |
Rectangle2D outline = new Rectangle2D.Double(pf.getImageableX(), pf |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
160 |
.getImageableY(), pf.getImageableWidth(), pf |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
161 |
.getImageableHeight()); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
162 |
g2.draw(outline); |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
163 |
return PAGE_EXISTS; |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
164 |
} |
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
165 |
|
df99c6e834bc
6966350: Empty pages when printing on Lexmark E352dn PS3 with "1200 IQ" setting
psadhukhan
parents:
diff
changeset
|
166 |
} |