Initial load
diff --git a/test/java/awt/PrintJob/ConstrainedPrintingTest/ConstrainedPrintingTest.java b/test/java/awt/PrintJob/ConstrainedPrintingTest/ConstrainedPrintingTest.java
new file mode 100644
index 0000000..f1b70d2
--- /dev/null
+++ b/test/java/awt/PrintJob/ConstrainedPrintingTest/ConstrainedPrintingTest.java
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+  @test
+  @bug 4116029 4300383
+  @summary verify that child components can draw only inside their
+           visible bounds
+  @author das@sparc.spb.su area=awt.print
+  @run main/manual=yesno ConstrainedPrintingTest
+*/
+
+// Note there is no @ in front of test above.  This is so that the
+//  harness will not mistake this file as a test file.  It should
+//  only see the html file as a test file. (the harness runs all
+//  valid test files, so it would run this test twice if this file
+//  were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag.  Here, you
+//  should put which functional area the test falls in.  See the
+//  AWT-core home page -> test areas and/or -> AWT team  for a list of
+//  areas.
+// There are several places where ManualYesNoTest appear.  It is
+//  recommended that these be changed by a global search and replace,
+//  such as  ESC-%  in xemacs.
+
+
+
+/**
+ * ConstrainedPrintingTest.java
+ *
+ * summary: verify that child components can draw only inside their
+ *          visible bounds
+ *
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+
+//Manual tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors.  (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems).  Also, you don't have to worry about
+// synchronisation stuff in Applet tests the way you do in main
+// tests...
+
+
+public class ConstrainedPrintingTest implements ActionListener
+ {
+   //Declare things used in the test, like buttons and labels here
+    final Frame frame = new Frame("PrintTest");
+    final Button button = new Button("Print");
+    final Panel panel = new Panel();
+    final Component testComponent = new Component() {
+        public void paint(Graphics g) {
+            ConstrainedPrintingTest.paintOutsideBounds(this, g, Color.green);
+        }
+        public Dimension getPreferredSize() {
+            return new Dimension(100, 100);
+        }
+    };
+    final Canvas testCanvas = new Canvas() {
+        public void paint(Graphics g) {
+            ConstrainedPrintingTest.paintOutsideBounds(this, g, Color.red);
+            // The frame is sized so that only the upper part of
+            // the canvas is visible. We draw on the lower part,
+            // so that we can verify that the output is clipped
+            // by the parent container bounds.
+            Dimension panelSize = panel.getSize();
+            Rectangle b = getBounds();
+            g.setColor(Color.red);
+            g.setClip(null);
+            for (int i = panelSize.height - b.y; i < b.height; i+= 10) {
+                g.drawLine(0, i, b.width, i);
+            }
+        }
+        public Dimension getPreferredSize() {
+            return new Dimension(100, 100);
+        }
+    };
+
+   public void init()
+    {
+      //Create instructions for the user here, as well as set up
+      // the environment -- set the layout manager, add buttons,
+      // etc.
+        button.addActionListener(this);
+
+        panel.setBackground(Color.white);
+        panel.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20));
+        panel.add(testComponent);
+        panel.add(testCanvas);
+
+        frame.setLayout(new BorderLayout());
+        frame.add(button, BorderLayout.NORTH);
+        frame.add(panel, BorderLayout.CENTER);
+        frame.setSize(200, 250);
+        frame.validate();
+        frame.setResizable(false);
+
+      String[] instructions =
+       {
+         "1.Look at the frame titled \"PrintTest\". If you see green or",
+         "  red lines on the white area below the \"Print\" button, the",
+         "  test fails. Otherwise go to step 2.",
+         "2.Press \"Print\" button. The print dialog will appear. Select",
+         "  a printer and proceed. Look at the output. If you see multiple",
+         "  lines outside of the frame bounds or in the white area below",
+         "  the image of the \"Print\" button, the test fails. Otherwise",
+         "  the test passes."
+       };
+      Sysout.createDialogWithInstructions( instructions );
+
+    }//End  init()
+
+   public void start ()
+    {
+      //Get things going.  Request focus, set size, et cetera
+
+        frame.setVisible(true);
+
+      //What would normally go into main() will probably go here.
+      //Use System.out.println for diagnostic messages that you want
+      // to read after the test is done.
+      //Use Sysout.println for messages you want the tester to read.
+
+    }// start()
+
+   //The rest of this class is the actions which perform the test...
+
+   //Use Sysout.println to communicate with the user NOT System.out!!
+   //Sysout.println ("Something Happened!");
+
+    public void stop() {
+        frame.setVisible(false);
+    }
+
+    public void destroy() {
+        frame.dispose();
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        PageAttributes pa = new PageAttributes();
+        pa.setPrinterResolution(36);
+        PrintJob pjob = frame.getToolkit().getPrintJob(frame, "NewTest",
+                                                       new JobAttributes(),
+                                                       pa);
+        if (pjob != null) {
+            Graphics pg = pjob.getGraphics();
+            if (pg != null) {
+                pg.translate(20, 20);
+                frame.printAll(pg);
+                pg.dispose();
+            }
+            pjob.end();
+        }
+    }
+
+    public static void paintOutsideBounds(Component comp,
+                                          Graphics g,
+                                          Color color) {
+        Dimension dim = comp.getSize();
+        g.setColor(color);
+
+        g.setClip(0, 0, dim.width * 2, dim.height * 2);
+        for (int i = 0; i < dim.height * 2; i += 10) {
+            g.drawLine(dim.width, i, dim.width * 2, i);
+        }
+
+        g.setClip(null);
+        for (int i = 0; i < dim.width * 2; i += 10) {
+            g.drawLine(i, dim.height, i, dim.height * 2);
+        }
+
+        g.setClip(new Rectangle(0, 0, dim.width * 2, dim.height * 2));
+        for (int i = 0; i < dim.width; i += 10) {
+            g.drawLine(dim.width * 2 - i, 0, dim.width * 2, i);
+        }
+    }
+
+    public static void main(String[] args) {
+        ConstrainedPrintingTest c = new ConstrainedPrintingTest();
+
+        c.init();
+        c.start();
+    }
+
+ }// class ConstrainedPrintingTest
+
+/* Place other classes related to the test after this line */
+
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+ {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.show();
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+ }// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+ {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("South", messageText);
+
+      pack();
+
+      show();
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
diff --git a/test/java/awt/PrintJob/EdgeTest/EdgeTest.java b/test/java/awt/PrintJob/EdgeTest/EdgeTest.java
new file mode 100644
index 0000000..56dd2dd
--- /dev/null
+++ b/test/java/awt/PrintJob/EdgeTest/EdgeTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4092755
+ * @summary Verifies that (0, 0) is the upper-left corner of the page, not
+ *          the upper-left corner adjusted for the margins.
+ * @author dpm
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class EdgeTest extends Panel {
+    public void init() {
+        Frame f = new Frame("EdgeTest");
+        f.setSize(50, 50);
+        f.addWindowListener( new WindowAdapter() {
+                                    public void windowClosing(WindowEvent ev) {
+                                        System.exit(0);
+                                    }
+                                }
+                            );
+        f.setVisible(true);
+        PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", null);
+        if (pj != null) {
+            Graphics g = pj.getGraphics();
+            Dimension d = pj.getPageDimension();
+            g.setColor(Color.black);
+            g.setFont(new Font("Serif", Font.PLAIN, 12));
+
+            //top
+            g.drawLine(0, 0, d.width, 0);
+
+            //left
+            g.drawLine(0, 0, 0, d.height);
+
+            //bottom
+            g.drawLine(0, d.height, d.width, d.height);
+
+            //right
+            g.drawLine(d.width, 0, d.width, d.height);
+
+            g.drawString("This page should have no borders!",
+                         d.width / 2 - 100, d.height / 2 - 10);
+            g.dispose();
+            pj.end();
+        }
+    }
+
+    public static void main(String[] args) {
+        new EdgeTest().init();
+    }
+}
diff --git a/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java b/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java
new file mode 100644
index 0000000..1f64d4f
--- /dev/null
+++ b/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4112758
+ * @summary Checks that a second invocation of PrintJob.end() does not cause
+ * an exception or segmentation violation.
+ * @author dpm
+ */
+
+import java.awt.*;
+
+public class MultipleEnd {
+    public static void main(String[] args) {
+        new MultipleEnd().start();
+    }
+    public void start() {
+        new MultipleEndFrame();
+    }
+}
+
+class MultipleEndFrame extends Frame {
+    public MultipleEndFrame() {
+        super("MultipleEnd");
+        setVisible(true);
+        PrintJob pj  = getToolkit().getPrintJob(this, "MuiltipleEnd", null);
+        if (pj != null) {
+            pj.end();
+            pj.end();
+        }
+    }
+}
diff --git a/test/java/awt/PrintJob/PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java b/test/java/awt/PrintJob/PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java
new file mode 100644
index 0000000..494be9b
--- /dev/null
+++ b/test/java/awt/PrintJob/PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+  @test
+  @bug 4507585
+  @summary Native modal dialog shouldn't block event dispatching when called on EventDispatchThread.
+  @author tav@sparc.spb.su: area=awt.PrintJob
+  @run main/manual=yesno PageSetupDlgBlockingTest
+
+*/
+
+import java.awt.*;
+import java.awt.print.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.applet.*;
+
+public class PageSetupDlgBlockingTest extends Panel {
+    public static Frame frame = new TestFrame("Test Frame");
+
+    public static void main(String[] args) {
+        PageSetupDlgBlockingTest a = new PageSetupDlgBlockingTest();
+
+        a.init();
+        a.start();
+    }
+
+    public void init()
+    {
+        //Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+
+        String[] instructions =
+        {
+            "This test verifies that native modal 'Page Setup' dialog doesn't block event",
+            "handling when called on EventDispatchThread.",
+            " ",
+            "After test started you will see 'Test Frame' frame which contains",
+            "one 'Click Me' button.",
+            "1. Click the button:",
+            "   - 'Page Setup' dialog will appear.",
+            "2. Drag the dialog over the 'Test Frame' so that to enforce its button redraw:",
+            "   - if you're seeing the button redraw (as long as PAINT events are displayed)",
+            "     the test PASSED else FAILED."
+        };
+        Sysout.createDialogWithInstructions(instructions);
+    }
+
+
+    public void start() {
+        JButton button = new JButton("Click Me");
+        final AWTEventListener listener = new AWTEventListener() {
+                public void eventDispatched(AWTEvent e) {
+                    if (e.getSource().getClass() == TestFrame.class) {
+                        Sysout.println(e.paramString() + " on <Test Frame>");
+                    }
+                }
+            };
+
+        button.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+
+                    // Show PAINT events only when the dialog is displayed.
+                    Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.PAINT_EVENT_MASK);
+
+                    PrinterJob job = PrinterJob.getPrinterJob();
+                    job.pageDialog(job.defaultPage());
+
+                    Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
+                }
+            });
+
+        button.setSize(100, 50);
+
+        frame.setLayout(new BorderLayout());
+        frame.setSize(200, 200);
+        frame.setLocation(500, 0);
+        frame.add(button, BorderLayout.CENTER);
+        frame.setVisible(true);
+    }
+}
+
+class TestFrame extends Frame {
+    TestFrame(String title) {
+        super(title);
+    }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
diff --git a/test/java/awt/PrintJob/PrintArcTest/PrintArcTest.java b/test/java/awt/PrintJob/PrintArcTest/PrintArcTest.java
new file mode 100644
index 0000000..8ad1d2a
--- /dev/null
+++ b/test/java/awt/PrintJob/PrintArcTest/PrintArcTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+   @test
+   @bug 4105609
+   @summary Test printing of drawArc preceded by drawString
+   @author robi.khan
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class PrintArcTest extends Panel implements ActionListener {
+    PrintCanvas canvas;
+
+    public PrintArcTest () {
+        setLayout(new BorderLayout());
+        canvas = new PrintCanvas ();
+        add("North", canvas);
+
+        Button b = new Button("Click Me to Print!");
+        b.setActionCommand ("print");
+        b.addActionListener (this);
+        add("South", b);
+        validate();
+    }
+
+
+    public void actionPerformed(ActionEvent e) {
+        String cmd = e.getActionCommand();
+        if (cmd.equals("print")) {
+            PrintJob pjob = getToolkit().getPrintJob(getFrame(), "Printing Test", null);
+            if (pjob != null) {
+                Graphics pg = pjob.getGraphics();
+
+                if (pg != null)  {
+                    canvas.printAll(pg);
+                    pg.dispose();  //flush page
+                }
+                pjob.end();
+            }
+        }
+    }
+
+    private Frame getFrame() {
+        Container cont = getParent();;
+
+        while ( !(cont instanceof Frame  ) ) {
+            cont = cont.getParent();
+        }
+
+        return (Frame)cont;
+    }
+
+    public static void main(String args[]) {
+        PrintArcTest test = new PrintArcTest();
+        Frame   f = new Frame( "PrintArcTest for Bug #4105609");
+        f.add( test );
+        f.setSize(500,400);
+        f.show();
+        f.addWindowListener( new WindowAdapter() {
+                                        public void windowClosing(WindowEvent ev) {
+                                            System.exit(0);
+                                        }
+                                    }
+                            );
+    }
+}
+
+class PrintCanvas extends Canvas {
+    public Dimension getPreferredSize() {
+            return new Dimension(300,300);
+    }
+
+    public void paint (Graphics g) {
+        g.drawString("drawArc(25,50,150,100,45,90);",25,25);
+        g.drawArc(25,50,150,100,45,90);
+
+        g.drawString("drawOval(25,200,200,40);",25,175);
+        g.drawOval(25,200,200,40);
+
+        g.dispose();
+    }
+}
diff --git a/test/java/awt/PrintJob/PrintCheckboxTest/PrintCheckboxManualTest.java b/test/java/awt/PrintJob/PrintCheckboxTest/PrintCheckboxManualTest.java
new file mode 100644
index 0000000..d2e16b3
--- /dev/null
+++ b/test/java/awt/PrintJob/PrintCheckboxTest/PrintCheckboxManualTest.java
@@ -0,0 +1,295 @@
+/*
+ * Copyright (c) 2004-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+  @test
+  @bug 5045936 5055171
+  @summary Tests that there is no ClassCastException thrown in printing
+   checkbox and scrollbar with XAWT
+  @author art@sparc.spb.su
+  @run applet/manual=yesno PrintCheckboxManualTest.html
+*/
+
+// Note there is no @ in front of test above.  This is so that the
+//  harness will not mistake this file as a test file.  It should
+//  only see the html file as a test file. (the harness runs all
+//  valid test files, so it would run this test twice if this file
+//  were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag.  Here, you
+//  should put which functional area the test falls in.  See the
+//  AWT-core home page -> test areas and/or -> AWT team  for a list of
+//  areas.
+
+
+
+import java.awt.*;
+import java.awt.event.*;
+
+
+//Manual tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors.  (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems).  Also, you don't have to worry about
+// synchronisation stuff in Applet tests the way you do in main
+// tests...
+
+
+public class PrintCheckboxManualTest extends Panel
+{
+    //Declare things used in the test, like buttons and labels here
+    Frame f;
+
+    public static void main(String[] args) {
+        PrintCheckboxManualTest a = new PrintCheckboxManualTest();
+
+        a.init();
+        a.start();
+    }
+
+    public void init()
+    {
+        //Create instructions for the user here, as well as set up
+        // the environment -- set the layout manager, add buttons,
+        // etc.
+        this.setLayout (new BorderLayout ());
+
+        String[] instructions =
+        {
+            "Linux or Solaris with XToolkit ONLY!",
+            "1. Click the 'Print' button on the frame",
+            "2. Select a printer in the print dialog and proceed",
+            "3. If the frame with checkbox and button on it is printed successfully test PASSED else FAILED"
+        };
+        Sysout.createDialogWithInstructions( instructions );
+
+    }//End  init()
+
+    public void start ()
+    {
+        //Get things going.  Request focus, set size, et cetera
+        setSize (200,200);
+        setVisible(true);
+        validate();
+
+        //What would normally go into main() will probably go here.
+        //Use System.out.println for diagnostic messages that you want
+        // to read after the test is done.
+        //Use Sysout.println for messages you want the tester to read.
+
+        f = new Frame("Print checkbox");
+        f.setLayout(new GridLayout(2, 2));
+        f.setSize(200, 100);
+
+        Checkbox ch = new Checkbox("123");
+        ch.setState(true);
+        f.add(ch);
+
+        Scrollbar sb = new Scrollbar(Scrollbar.HORIZONTAL);
+        f.add(sb);
+
+        Button b = new Button("Print");
+        b.addActionListener(new ActionListener()
+        {
+        public void actionPerformed(ActionEvent ev)
+        {
+                PrintJob pj = Toolkit.getDefaultToolkit().getPrintJob(f, "PrintCheckboxManualTest", null);
+                if (pj != null)
+                {
+                        try
+                        {
+                                Graphics g = pj.getGraphics();
+                                f.printAll(g);
+                                g.dispose();
+                                pj.end();
+                                Sysout.println("Test PASSED");
+                        }
+                        catch (ClassCastException cce)
+                        {
+                                Sysout.println("Test FAILED: ClassCastException");
+//                              throw new RuntimeException("Test FAILED: ClassCastException", cce);
+                        }
+                        catch (Exception e)
+                        {
+                                Sysout.println("Test FAILED: unknown Exception");
+//                              throw new Error("Test FAILED: unknown exception", e);
+                        }
+                }
+        }
+        });
+        f.add(b);
+
+        f.setVisible(true);
+    }// start()
+
+    //The rest of this class is the actions which perform the test...
+
+    //Use Sysout.println to communicate with the user NOT System.out!!
+    //Sysout.println ("Something Happened!");
+
+}
+
+/* Place other classes related to the test after this line */
+
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+  chunk of code whose purpose is to make user
+  interaction uniform, and thereby make it simpler
+  to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+  for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+  WithInstructions method.  Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+  with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+  as standalone.
+ */
+
+class Sysout
+{
+    private static TestDialog dialog;
+
+    public static void createDialogWithInstructions( String[] instructions )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        dialog.printInstructions( instructions );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+    public static void createDialog( )
+    {
+        dialog = new TestDialog( new Frame(), "Instructions" );
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
+        dialog.printInstructions( defInstr );
+        dialog.setVisible(true);
+        println( "Any messages for the tester will display here." );
+    }
+
+
+    public static void printInstructions( String[] instructions )
+    {
+        dialog.printInstructions( instructions );
+    }
+
+
+    public static void println( String messageIn )
+    {
+        dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog
+{
+
+    TextArea instructionsText;
+    TextArea messageText;
+    int maxStringLength = 80;
+
+    //DO NOT call this directly, go through Sysout
+    public TestDialog( Frame frame, String name )
+    {
+        super( frame, name );
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+        add( "North", instructionsText );
+
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+        add("Center", messageText);
+
+        pack();
+
+        setVisible(true);
+    }// TestDialog()
+
+    //DO NOT call this directly, go through Sysout
+    public void printInstructions( String[] instructions )
+    {
+        //Clear out any current instructions
+        instructionsText.setText( "" );
+
+        //Go down array of instruction strings
+
+        String printStr, remainingStr;
+        for( int i=0; i < instructions.length; i++ )
+        {
+            //chop up each into pieces maxSringLength long
+            remainingStr = instructions[ i ];
+            while( remainingStr.length() > 0 )
+            {
+                //if longer than max then chop off first max chars to print
+                if( remainingStr.length() >= maxStringLength )
+                {
+                    //Try to chop on a word boundary
+                    int posOfSpace = remainingStr.
+                        lastIndexOf( ' ', maxStringLength - 1 );
+
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
+                }
+                //else just print
+                else
+                {
+                    printStr = remainingStr;
+                    remainingStr = "";
+                }
+
+                instructionsText.append( printStr + "\n" );
+
+            }// while
+
+        }// for
+
+    }//printInstructions()
+
+    //DO NOT call this directly, go through Sysout
+    public void displayMessage( String messageIn )
+    {
+        messageText.append( messageIn + "\n" );
+        System.out.println(messageIn);
+    }
+
+}// TestDialog  class
diff --git a/test/java/awt/PrintJob/QuoteAndBackslashTest/QuoteAndBackslashTest.java b/test/java/awt/PrintJob/QuoteAndBackslashTest/QuoteAndBackslashTest.java
new file mode 100644
index 0000000..2ac6c5f
--- /dev/null
+++ b/test/java/awt/PrintJob/QuoteAndBackslashTest/QuoteAndBackslashTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4040668
+ * @summary Checks that banner titles which contain double quotation marks
+ * or backslashes still print correctly.
+ * @author dpm
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+
+
+public class QuoteAndBackslashTest {
+    public static void main(String[] args) {
+        new QuoteAndBackslashTest().start();
+    }
+    public void start() {
+        new QuoteAndBackslashTestFrame();
+    }
+}
+
+class QuoteAndBackslashTestFrame extends Frame implements ActionListener {
+    PrintCanvas canvas;
+
+    public QuoteAndBackslashTestFrame () {
+        super("QuoteAndBackslashTest");
+        canvas = new PrintCanvas ();
+        add("Center", canvas);
+
+        Button b = new Button("Print");
+        b.setActionCommand ("print");
+        b.addActionListener (this);
+        add("South", b);
+
+        pack();
+        setVisible(true);
+    }
+
+
+    public void actionPerformed(ActionEvent e) {
+        String cmd = e.getActionCommand();
+        if (cmd.equals("print")) {
+            PrintJob pjob = getToolkit().getPrintJob(this, "\\\"\"\\\"",
+                                                     null);
+            if (pjob != null) {
+                Graphics pg = pjob.getGraphics();
+
+                if (pg != null)  {
+                    canvas.printAll(pg);
+                    pg.dispose();  //flush page
+                }
+
+                pjob.end();
+            }
+        }
+    }
+}
+
+class PrintCanvas extends Canvas {
+    public Dimension getPreferredSize() {
+        return new Dimension(659, 792);
+    }
+
+    public void paint (Graphics g) {
+        setBackground(Color.white);
+        g.setColor(Color.blue);
+        g.fillRoundRect(50, 50, 100, 200, 50, 50);
+    }
+}
diff --git a/test/java/awt/PrintJob/RoundedRectTest/RoundedRectTest.java b/test/java/awt/PrintJob/RoundedRectTest/RoundedRectTest.java
new file mode 100644
index 0000000..ad17c70
--- /dev/null
+++ b/test/java/awt/PrintJob/RoundedRectTest/RoundedRectTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4061440
+ * @summary Checks that rounded rectangles print correctly.
+ * @author dpm
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class RoundedRectTest {
+    public static void main(String[] args) {
+        new RoundedRectTest().start();
+    }
+    public void start() {
+        new RoundedRectTestFrame();
+    }
+}
+
+class RoundedRectTestFrame extends Frame implements ActionListener {
+    PrintCanvas canvas;
+
+    public RoundedRectTestFrame () {
+        super("RoundedRectTest");
+        canvas = new PrintCanvas ();
+        add("Center", canvas);
+
+        Button b = new Button("Print");
+        b.setActionCommand ("print");
+        b.addActionListener (this);
+        add("South", b);
+
+        pack();
+        setVisible(true);
+    }
+
+
+    public void actionPerformed(ActionEvent e) {
+        String cmd = e.getActionCommand();
+        if (cmd.equals("print")) {
+            PrintJob pjob = getToolkit().getPrintJob(this, "RoundedRectTest",
+                                                     null);
+            if (pjob != null) {
+                Graphics pg = pjob.getGraphics();
+
+                if (pg != null)  {
+                    canvas.printAll(pg);
+                    pg.dispose();  //flush page
+                }
+
+                pjob.end();
+            }
+        }
+    }
+}
+
+class PrintCanvas extends Canvas {
+    public Dimension getPreferredSize() {
+        return new Dimension(659, 792);
+    }
+
+    public void paint (Graphics g) {
+        setBackground(Color.white);
+        g.setColor(Color.blue);
+        g.fillRoundRect(50, 50, 100, 200, 50, 50);
+        g.fillRoundRect(200, 50, 100, 100, 50, 50);
+        g.fillRoundRect(350, 50, 200, 100, 50, 50);
+
+        g.fillRoundRect(50, 300, 100, 200, 41, 97);
+        g.fillRoundRect(200, 300, 100, 100, 41, 97);
+        g.fillRoundRect(350, 300, 200, 100, 41, 97);
+
+        g.fillRoundRect(50, 550, 100, 200, 97, 41);
+        g.fillRoundRect(200, 550, 100, 100, 97, 41);
+        g.fillRoundRect(350, 550, 200, 100, 97, 41);
+    }
+}
diff --git a/test/java/awt/PrintJob/SaveDialogTitleTest.java b/test/java/awt/PrintJob/SaveDialogTitleTest.java
new file mode 100644
index 0000000..0937978
--- /dev/null
+++ b/test/java/awt/PrintJob/SaveDialogTitleTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4851363
+ * @summary Tests the save to file dialog has a title
+ * @run main/manual=yesno/othervm SaveDialogTitleTest
+ */
+
+import java.awt.*;
+
+public class SaveDialogTitleTest {
+
+    public static void main(String args[]) {
+
+        System.out.print("Once the dialog appears, press OK and the ");
+        System.out.print("Save to File dialog should appear and it ");
+        System.out.println("must have a window title else the test fails.");
+        Toolkit tk = Toolkit.getDefaultToolkit();
+        JobAttributes jobAttributes = new JobAttributes();
+        jobAttributes.setDestination(JobAttributes.DestinationType.FILE);
+        PrintJob printJob =
+            tk.getPrintJob(new Frame(), "Save Title Test",
+                           jobAttributes, null);
+        if (printJob != null) { // in case user cancels.
+          printJob.end();
+        }
+        System.exit(0); // safe because use 'othervm'
+    }
+}
diff --git a/test/java/awt/PrintJob/Text/StringWidth.java b/test/java/awt/PrintJob/Text/StringWidth.java
new file mode 100644
index 0000000..258bb0e
--- /dev/null
+++ b/test/java/awt/PrintJob/Text/StringWidth.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.awt.*;
+import java.util.Properties;
+import sun.awt.*;
+
+public class StringWidth extends Frame {
+
+  public StringWidth() {
+    Font plain = new Font("Dialog", Font.PLAIN, 10);
+    Font bold = new Font("Dialog", Font.BOLD, 10);
+    Properties props = new Properties();
+    int x, y;
+
+    // we must have visible Frame context for PrintDialog in Solaris
+    setSize(400, 300);
+    setVisible(true);
+
+    PrintJob pj = getToolkit().getPrintJob(this, "", props);
+    if (pj == null) {
+        return;
+    }
+    Graphics  pg = pj.getGraphics();
+
+
+    String test = "Hello World!";
+
+    FontMetrics plainFm = pg.getFontMetrics(plain);
+    FontMetrics boldFm = pg.getFontMetrics(bold);
+    Dimension size = pj.getPageDimension();
+
+    // now right justify on the printed page
+    int center = size.width/2;
+    y = 150;
+    x = center - plainFm.stringWidth(test);
+    pg.setFont(plain);
+    pg.drawString(test, x-1, y);
+
+    pg.dispose();
+    pj.end();
+    setVisible(false);
+    System.exit(0);
+  }
+
+  public static void main(String[] args) {
+    new StringWidth();
+  }
+
+}
diff --git a/test/java/awt/PrintJob/Text/stringwidth.sh b/test/java/awt/PrintJob/Text/stringwidth.sh
new file mode 100644
index 0000000..354cff5
--- /dev/null
+++ b/test/java/awt/PrintJob/Text/stringwidth.sh
@@ -0,0 +1,43 @@
+#!/bin/ksh -p
+#
+#   @test      
+#   @bug        4692562
+#   @summary    Requirement: Windows with printer installed.  It should print with text "Hello World".
+#   @compile StringWidth.java
+#   @run shell/manual stringwidth.sh
+#
+OS=`uname`
+
+status=1
+checkstatus()
+ {
+  status=$?
+  if [ $status -ne "0" ]; then
+    exit "$status"
+  fi
+ }
+
+# pick up the compiled class files.
+if [ -z "${TESTCLASSES}" ]; then
+  CP="."
+else
+  CP="${TESTCLASSES}"
+fi
+
+
+if [ $OS = SunOS -o $OS = Linux ]
+then
+    exit 0
+fi
+# Windows
+
+if [ -z "${TESTJAVA}" ] ; then
+   JAVA_HOME=../../../../../../build/windows-i586
+else
+   JAVA_HOME=$TESTJAVA
+fi
+
+    $JAVA_HOME/bin/java -cp "${CP}" StringWidth
+    checkstatus
+
+exit 0