jdk/test/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java
author psadhukhan
Thu, 22 Dec 2016 18:30:27 +0530
changeset 43077 785bbcd9812a
permissions -rw-r--r--
8170349: The printed content is beyond the borders Reviewed-by: alexsch, aniyogi
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43077
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     1
/*
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     4
 *
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     8
 *
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    13
 * accompanied this code).
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    14
 *
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    18
 *
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    21
 * questions.
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    22
 */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    23
/*
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    24
 * @test
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    25
 * @bug 8170349
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    26
 * @summary  Verify if printed content is within border and all columns are
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    27
 *           printed for PrintMode.FIT_WIDTH
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    28
 * @run main/manual PrintManualTest_FitWidthMultiple
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    29
 */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    30
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    31
import java.awt.BorderLayout;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    32
import java.awt.event.ActionEvent;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    33
import java.awt.event.ActionListener;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    34
import java.awt.event.WindowAdapter;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    35
import java.awt.event.WindowEvent;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    36
import java.text.MessageFormat;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    37
import java.util.concurrent.CountDownLatch;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    38
import java.util.concurrent.TimeUnit;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    39
import javax.print.attribute.HashPrintRequestAttributeSet;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    40
import javax.print.attribute.PrintRequestAttributeSet;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    41
import javax.swing.AbstractAction;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    42
import javax.swing.JButton;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    43
import javax.swing.JComponent;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    44
import javax.swing.JFrame;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    45
import javax.swing.JPanel;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    46
import javax.swing.JScrollPane;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    47
import javax.swing.JTable;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    48
import javax.swing.JTextArea;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    49
import javax.swing.KeyStroke;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    50
import javax.swing.SwingUtilities;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    51
import javax.swing.table.AbstractTableModel;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    52
import javax.swing.table.TableModel;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    53
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    54
public class PrintManualTest_FitWidthMultiple extends JTable implements Runnable {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    55
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    56
    static boolean testPassed;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    57
    static JFrame fr = null;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    58
    static JFrame instructFrame = null;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    59
    private final CountDownLatch latch;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    60
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    61
    public PrintManualTest_FitWidthMultiple(CountDownLatch latch){
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    62
        this.latch = latch;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    63
    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    64
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    65
    @Override
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    66
    public void run() {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    67
        try {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    68
            createUIandTest();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    69
        } catch (Exception ex) {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    70
            dispose();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    71
            latch.countDown();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    72
            throw new RuntimeException(ex.getMessage());
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    73
        }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    74
    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    75
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    76
    private void createUIandTest() throws Exception {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    77
        /*Message Format Header and Footer */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    78
        final MessageFormat header=new MessageFormat("JTable Printing Header {0}");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    79
        final MessageFormat footer = new MessageFormat("JTable Printing Footer {0}");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    80
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    81
        SwingUtilities.invokeAndWait(new Runnable() {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    82
            @Override
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    83
            public void run() {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    84
                /* Instructions Section */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    85
                String info =
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    86
                    " \nThis test case brings up JTable with more Columns and Rows \n"+
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    87
                    "Press the Print Button. It Prints in PRINT_MODE_FIT_WIDTH \n" +
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    88
                    "It Pops up the Print Dialog. Check if Job/Print Attributes in the\n" +
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    89
                    "Print Dialog are configurable. Default Print out will be in Landscape \n"+
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    90
                    "The Print out should have JTable Centered on the Print out with thin borders \n"+
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    91
                    "Prints out with Header and Footer. \n"+
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    92
                    "The JTable should have all columns printed within border";
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    93
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    94
                instructFrame=new JFrame("PrintManualTest_NormalSingle");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    95
                JPanel panel=new JPanel(new BorderLayout());
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    96
                JButton button1 = new JButton("Pass");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    97
                JButton button2 = new JButton("Fail");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    98
                button1.addActionListener((e) -> {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
    99
                    testPassed = true;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   100
                    dispose();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   101
                    latch.countDown();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   102
                });
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   103
                button2.addActionListener((e) -> {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   104
                    testPassed = false;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   105
                    dispose();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   106
                    latch.countDown();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   107
                });
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   108
                JPanel btnpanel1 = new JPanel();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   109
                btnpanel1.add(button1);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   110
                btnpanel1.add(button2);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   111
                panel.add(addInfo(info),BorderLayout.CENTER);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   112
                panel.add(btnpanel1, BorderLayout.SOUTH);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   113
                instructFrame.getContentPane().add(panel);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   114
                instructFrame.setBounds(600,100,350,350);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   115
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   116
                /* Print Button */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   117
                final JButton printButton=new JButton("Print");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   118
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   119
                /* Table Model */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   120
                final TableModel datamodel=new AbstractTableModel(){
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   121
                    @Override
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   122
                    public int getColumnCount() { return 50;}
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   123
                    @Override
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   124
                    public int getRowCount() { return 50; }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   125
                    @Override
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   126
                    public Object getValueAt(int row, int column){ return new Integer(row*column);}
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   127
                };
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   128
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   129
                /* Constructing the JTable */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   130
                final JTable table=new JTable(datamodel);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   131
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   132
                /* Putting the JTable in ScrollPane and Frame Container */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   133
                JScrollPane scrollpane=new JScrollPane(table);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   134
                fr = new JFrame("PrintManualTest_FitWidthMultiple");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   135
                fr.getContentPane().add(scrollpane);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   136
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   137
                /* Light Weight Panel for holding Print and other buttons */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   138
                JPanel btnpanel=new JPanel();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   139
                btnpanel.add(printButton);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   140
                fr.getContentPane().add(btnpanel,BorderLayout.SOUTH);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   141
                fr.setBounds(0,0,400,400);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   142
                fr.setSize(500,500);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   143
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   144
                /* Binding the KeyStroke to Print Button Action */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   145
                fr.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl P"), "printButton");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   146
                fr.getRootPane().getActionMap().put("printButton", new AbstractAction(){
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   147
                    @Override
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   148
                    public void actionPerformed(ActionEvent e){
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   149
                        printButton.doClick();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   150
                    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   151
                });
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   152
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   153
                /* Container and Component Listeners */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   154
                fr.addWindowListener(new WindowAdapter() {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   155
                    @Override
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   156
                    public void windowClosing(WindowEvent e) {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   157
                        dispose();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   158
                        if (testPassed == false) {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   159
                            throw new RuntimeException(" User has not executed the test");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   160
                        }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   161
                    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   162
                });
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   163
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   164
                final PrintRequestAttributeSet prattr=new HashPrintRequestAttributeSet();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   165
                prattr.add(javax.print.attribute.standard.OrientationRequested.LANDSCAPE);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   166
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   167
                printButton.addActionListener(new ActionListener(){
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   168
                    @Override
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   169
                    public void actionPerformed(ActionEvent ae){
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   170
                        try{
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   171
                            table.print(JTable.PrintMode.FIT_WIDTH, header,footer,true,prattr,true);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   172
                        } catch(Exception e){}
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   173
                    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   174
                });
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   175
                instructFrame.setVisible(true);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   176
                fr.setVisible(true);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   177
            }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   178
        });
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   179
    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   180
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   181
    public void dispose() {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   182
        instructFrame.dispose();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   183
        fr.dispose();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   184
    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   185
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   186
    public JScrollPane addInfo(String info) {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   187
        JTextArea jta = new JTextArea(info,8,20);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   188
        jta.setEditable(false);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   189
        jta.setLineWrap(true);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   190
        JScrollPane sp = new JScrollPane(jta);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   191
        return sp;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   192
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   193
    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   194
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   195
    /* Main Method */
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   196
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   197
    public static void main(String[] argv) throws Exception {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   198
        final CountDownLatch latch = new CountDownLatch(1);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   199
        PrintManualTest_FitWidthMultiple test = new PrintManualTest_FitWidthMultiple(latch);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   200
        Thread T1 = new Thread(test);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   201
        T1.start();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   202
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   203
        // wait for latch to complete
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   204
        boolean ret = false;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   205
        try {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   206
            ret = latch.await(60, TimeUnit.SECONDS);
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   207
        } catch (InterruptedException ie) {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   208
            throw ie;
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   209
        }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   210
        if (!ret) {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   211
            test.dispose();
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   212
            throw new RuntimeException(" User has not executed the test");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   213
        }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   214
        if (test.testPassed == false) {
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   215
            throw new RuntimeException("printed contents is beyond borders");
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   216
        }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   217
    }
785bbcd9812a 8170349: The printed content is beyond the borders
psadhukhan
parents:
diff changeset
   218
}