Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6708509
Votes 0
Synopsis print dialog is not displayed when default paper is custom
Category java:classes_2d
Reported Against
Release Fixed 7(b33), 6u10(b26) (Bug ID:2163345)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 29-MAY-2008
Description
While testing the following test program with Dymo Label Printer 330 Turbo, the program just exits without any print dialog or error message.  Other printer drivers like laser printer drivers shows the dialog.  It is not always reproducible.

import java.util.Vector;
import java.awt.print.*;
import java.awt.*;
import javax.swing.JPanel;

public class DymoLabelPrinting{

    public static void main(String args[])
    {
        Vector vLabels = new Vector();
        vLabels.add("Mr.TIGERWOODS");
        vLabels.add("H NO 2-7, AMEERPET");
        vLabels.add("HYDERABAD");
        vLabels.add("ANDHRA PRADESH,INDIA");

        PrintLabels printLabels = new PrintLabels(vLabels);

        printLabels.prepareLabels();

        Thread labelPrintingThread=new Thread(printLabels);

        labelPrintingThread.start();
    }
}

//-------------------------------------------

class PrintLabels implements Runnable
{


    Vector records;
    String strOrientation;

    PageFormat pageFormat;
    PrinterJob printJob;

    Page page ;

    public PrintLabels(Vector vector)
    {
        pageFormat             = null;
        printJob             = null;
        strOrientation             = "Landscape";
        records             = vector;
    }

    public void run()
    {
        print();
    }

    public void prepareLabels()
    {
        page = new Page();
        page.addLabel(records);
    }


    public void print()
    {
        printJob = PrinterJob.getPrinterJob();

        try
        {
            Paper paper = new Paper();
            paper.setSize(165, 288);
            paper.setImageableArea(7, 0, 165, 288);

            pageFormat = printJob.defaultPage();
            pageFormat.setPaper(paper);

            if(strOrientation.equals("Portrait"))
                pageFormat.setOrientation(pageFormat.PORTRAIT);
            else
                pageFormat.setOrientation(pageFormat.LANDSCAPE);


            printJob.setPrintable(page, pageFormat);

            if(printJob.printDialog()==false)
                return;

            printJob.print();

        }catch(PrinterException e){
            e.printStackTrace();
        }

    }

}
------------------------------------------------------
Posted Date : 2008-05-29 16:13:51.0
Work Around
N/A
Evaluation
JDK thinks there is no default printer so it did not try to display the dialog this is because one of the conditions for finding out if there's a default printer is if DM_PAPERSIZE of DEVMODE is initialized.  For this particular driver where all paper sizes are non-standard Windows, driver sometimes only initializes DM_PAPERWIDTH and DM_PAPER_LENGTH but not DM_PAPERSIZE.
Posted Date : 2008-05-29 16:33:19.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang