Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/PrintJob/QuoteAndBackslashTest/QuoteAndBackslashTest.java
38828 views
/*1* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 404066826* @summary Checks that banner titles which contain double quotation marks27* or backslashes still print correctly.28* @author dpm29*/3031import java.awt.*;32import java.awt.event.*;333435public class QuoteAndBackslashTest {36public static void main(String[] args) {37new QuoteAndBackslashTest().start();38}39public void start() {40new QuoteAndBackslashTestFrame();41}42}4344class QuoteAndBackslashTestFrame extends Frame implements ActionListener {45PrintCanvas canvas;4647public QuoteAndBackslashTestFrame () {48super("QuoteAndBackslashTest");49canvas = new PrintCanvas ();50add("Center", canvas);5152Button b = new Button("Print");53b.setActionCommand ("print");54b.addActionListener (this);55add("South", b);5657pack();58setVisible(true);59}606162public void actionPerformed(ActionEvent e) {63String cmd = e.getActionCommand();64if (cmd.equals("print")) {65PrintJob pjob = getToolkit().getPrintJob(this, "\\\"\"\\\"",66null);67if (pjob != null) {68Graphics pg = pjob.getGraphics();6970if (pg != null) {71canvas.printAll(pg);72pg.dispose(); //flush page73}7475pjob.end();76}77}78}79}8081class PrintCanvas extends Canvas {82public Dimension getPreferredSize() {83return new Dimension(659, 792);84}8586public void paint (Graphics g) {87setBackground(Color.white);88g.setColor(Color.blue);89g.fillRoundRect(50, 50, 100, 200, 50, 50);90}91}929394