author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2 | 1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
24 |
/** |
|
25 |
* @test |
|
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
5506
diff
changeset
|
26 |
* @key headful |
2 | 27 |
* @bug 4040668 |
28 |
* @summary Checks that banner titles which contain double quotation marks |
|
29 |
* or backslashes still print correctly. |
|
30 |
* @author dpm |
|
31 |
*/ |
|
32 |
||
33 |
import java.awt.*; |
|
34 |
import java.awt.event.*; |
|
35 |
||
36 |
||
37 |
public class QuoteAndBackslashTest { |
|
38 |
public static void main(String[] args) { |
|
39 |
new QuoteAndBackslashTest().start(); |
|
40 |
} |
|
41 |
public void start() { |
|
42 |
new QuoteAndBackslashTestFrame(); |
|
43 |
} |
|
44 |
} |
|
45 |
||
46 |
class QuoteAndBackslashTestFrame extends Frame implements ActionListener { |
|
47 |
PrintCanvas canvas; |
|
48 |
||
49 |
public QuoteAndBackslashTestFrame () { |
|
50 |
super("QuoteAndBackslashTest"); |
|
51 |
canvas = new PrintCanvas (); |
|
52 |
add("Center", canvas); |
|
53 |
||
54 |
Button b = new Button("Print"); |
|
55 |
b.setActionCommand ("print"); |
|
56 |
b.addActionListener (this); |
|
57 |
add("South", b); |
|
58 |
||
59 |
pack(); |
|
60 |
setVisible(true); |
|
61 |
} |
|
62 |
||
63 |
||
64 |
public void actionPerformed(ActionEvent e) { |
|
65 |
String cmd = e.getActionCommand(); |
|
66 |
if (cmd.equals("print")) { |
|
67 |
PrintJob pjob = getToolkit().getPrintJob(this, "\\\"\"\\\"", |
|
68 |
null); |
|
69 |
if (pjob != null) { |
|
70 |
Graphics pg = pjob.getGraphics(); |
|
71 |
||
72 |
if (pg != null) { |
|
73 |
canvas.printAll(pg); |
|
74 |
pg.dispose(); //flush page |
|
75 |
} |
|
76 |
||
77 |
pjob.end(); |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
} |
|
82 |
||
83 |
class PrintCanvas extends Canvas { |
|
84 |
public Dimension getPreferredSize() { |
|
85 |
return new Dimension(659, 792); |
|
86 |
} |
|
87 |
||
88 |
public void paint (Graphics g) { |
|
89 |
setBackground(Color.white); |
|
90 |
g.setColor(Color.blue); |
|
91 |
g.fillRoundRect(50, 50, 100, 200, 50, 50); |
|
92 |
} |
|
93 |
} |