< prev index next >

test/java/awt/print/PrinterJob/PrintTestLexmarkIQ.java

Print this page




   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  * @test
  25  * @bug 6966350
  26  * @summary Verifies if Empty pages are printed on Lexmark E352dn PS3
  27  *           with "1200 IQ" setting
  28  * @run main/manual PrintTestLexmarkIQ
  29  */
  30 import java.awt.BorderLayout;
  31 import java.awt.Color;
  32 import java.awt.FlowLayout;
  33 import java.awt.Font;
  34 import java.awt.Graphics;
  35 import java.awt.Graphics2D;


  36 import java.awt.geom.Rectangle2D;
  37 import java.awt.print.PageFormat;
  38 import java.awt.print.Paper;
  39 import java.awt.print.Printable;
  40 import static java.awt.print.Printable.NO_SUCH_PAGE;
  41 import static java.awt.print.Printable.PAGE_EXISTS;
  42 import java.awt.print.PrinterException;
  43 import java.awt.print.PrinterJob;
  44 import javax.swing.JButton;
  45 import javax.swing.JDialog;
  46 import javax.swing.JPanel;
  47 import javax.swing.JTextArea;
  48 import javax.swing.SwingUtilities;
  49 
  50 public class PrintTestLexmarkIQ implements Printable {
  51 
  52     private static Thread mainThread;
  53     private static boolean testPassed;
  54     private static boolean testGeneratedInterrupt;
  55 


 128         failButton.addActionListener((e) -> {
 129             dialog.dispose();
 130             fail();
 131         });
 132         testButton.addActionListener((e) -> {
 133             testButton.setEnabled(false);
 134             action.run();
 135             passButton.setEnabled(true);
 136             failButton.setEnabled(true);
 137         });
 138         JPanel mainPanel = new JPanel(new BorderLayout());
 139         mainPanel.add(textArea, BorderLayout.CENTER);
 140         JPanel buttonPanel = new JPanel(new FlowLayout());
 141         buttonPanel.add(testButton);
 142         buttonPanel.add(passButton);
 143         buttonPanel.add(failButton);
 144         mainPanel.add(buttonPanel, BorderLayout.SOUTH);
 145         dialog.add(mainPanel);
 146         dialog.pack();
 147         dialog.setVisible(true);







 148     }
 149 
 150     public int print(Graphics g, PageFormat pf, int pi)
 151             throws PrinterException {
 152         if (pi != 0) {
 153             return NO_SUCH_PAGE;
 154         }
 155         Graphics2D g2 = (Graphics2D) g;
 156         g2.setFont(new Font("Serif", Font.PLAIN, 36));
 157         g2.setPaint(Color.black);
 158         g2.drawString("Java Source and Support", 100, 100);
 159         Rectangle2D outline = new Rectangle2D.Double(pf.getImageableX(), pf
 160                 .getImageableY(), pf.getImageableWidth(), pf
 161                 .getImageableHeight());
 162         g2.draw(outline);
 163         return PAGE_EXISTS;
 164     }
 165 
 166 }


   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  * @test
  25  * @bug 6966350 8160882
  26  * @summary Verifies if Empty pages are printed on Lexmark E352dn PS3
  27  *           with "1200 IQ" setting
  28  * @run main/manual PrintTestLexmarkIQ
  29  */
  30 import java.awt.BorderLayout;
  31 import java.awt.Color;
  32 import java.awt.FlowLayout;
  33 import java.awt.Font;
  34 import java.awt.Graphics;
  35 import java.awt.Graphics2D;
  36 import java.awt.event.WindowAdapter;
  37 import java.awt.event.WindowEvent;
  38 import java.awt.geom.Rectangle2D;
  39 import java.awt.print.PageFormat;
  40 import java.awt.print.Paper;
  41 import java.awt.print.Printable;
  42 import static java.awt.print.Printable.NO_SUCH_PAGE;
  43 import static java.awt.print.Printable.PAGE_EXISTS;
  44 import java.awt.print.PrinterException;
  45 import java.awt.print.PrinterJob;
  46 import javax.swing.JButton;
  47 import javax.swing.JDialog;
  48 import javax.swing.JPanel;
  49 import javax.swing.JTextArea;
  50 import javax.swing.SwingUtilities;
  51 
  52 public class PrintTestLexmarkIQ implements Printable {
  53 
  54     private static Thread mainThread;
  55     private static boolean testPassed;
  56     private static boolean testGeneratedInterrupt;
  57 


 130         failButton.addActionListener((e) -> {
 131             dialog.dispose();
 132             fail();
 133         });
 134         testButton.addActionListener((e) -> {
 135             testButton.setEnabled(false);
 136             action.run();
 137             passButton.setEnabled(true);
 138             failButton.setEnabled(true);
 139         });
 140         JPanel mainPanel = new JPanel(new BorderLayout());
 141         mainPanel.add(textArea, BorderLayout.CENTER);
 142         JPanel buttonPanel = new JPanel(new FlowLayout());
 143         buttonPanel.add(testButton);
 144         buttonPanel.add(passButton);
 145         buttonPanel.add(failButton);
 146         mainPanel.add(buttonPanel, BorderLayout.SOUTH);
 147         dialog.add(mainPanel);
 148         dialog.pack();
 149         dialog.setVisible(true);
 150         dialog.addWindowListener(new WindowAdapter() {
 151             public void windowClosing(WindowEvent e) {
 152                 System.out.println("main dialog closing");
 153                 testGeneratedInterrupt = false;
 154                 mainThread.interrupt();
 155             }
 156         });
 157     }
 158 
 159     public int print(Graphics g, PageFormat pf, int pi)
 160             throws PrinterException {
 161         if (pi != 0) {
 162             return NO_SUCH_PAGE;
 163         }
 164         Graphics2D g2 = (Graphics2D) g;
 165         g2.setFont(new Font("Serif", Font.PLAIN, 36));
 166         g2.setPaint(Color.black);
 167         g2.drawString("Java Source and Support", 100, 100);
 168         Rectangle2D outline = new Rectangle2D.Double(pf.getImageableX(), pf
 169                 .getImageableY(), pf.getImageableWidth(), pf
 170                 .getImageableHeight());
 171         g2.draw(outline);
 172         return PAGE_EXISTS;
 173     }
 174 
 175 }
< prev index next >