While testing the bug fix for BugId 4273333 (jdk 1.3.1) on windows, Telcordia
found this new bug:
I tested out the fix for bug ID 4273333 - Print dialog is not modal. The
dialog is modal now, however, when I move the print dialog, the java window
behind the dialog is not repainted.
Testcase:
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import java.io.*;
import javax.swing.*;
import javax.swing.JFrame;
public class TestPrint implements Printable
{
private String data = null;
private PrinterJob printJob;
private JButton mybutton ;
public TestPrint( String text )
{
data = text;
printJob = PrinterJob.getPrinterJob();
printJob.setPrintable( this );
}
public void printIt()
{
if( printJob.printDialog() ) {
System.out.println("Will Print because OK clicked");
}
else
System.out.println("Won't Print because Cancel Clicked");
}
/**
* print : Printable interface method
* is not doing anything right now since the intention is to show the
* non-modal nature of the print dialog.
*/
public int print( Graphics g, PageFormat pf, int pageIndex ) throws PrinterException
{
System.out.println("Print called");
return 0;
}//end of print
/**
* main - starting point for the appl.
* Does following Creates Text data, Sets it to the TextArea, and
*/
public static void main( String[] args )
{
String nl = System.getProperty("line.separator");
final String text = new String(
"Twinkle twinkle little stars" + nl +
"how i wonder what you are" + nl +
"up above the sky so high " + nl +
"like a something in the sky" + nl);
JFrame frame = new JFrame();
Container panel = frame.getContentPane();
panel.setLayout( new BorderLayout() );
JTextArea ta = new JTextArea( 8, 100 );
ta.setText( text );
panel.add( ta, BorderLayout.NORTH );
JButton myButton = new JButton("Print Out");
panel.add( myButton, BorderLayout.SOUTH );
myButton.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e )
{
TestPrint p = new TestPrint( text );
p.printIt();
}} );
frame.setSize( 400, 200 );
frame.setVisible( true );
}//end of main
}//end of class