Name: jk109818 Date: 07/29/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
I am trying to write a program that will perform
silent printing to a card printer. Everything seems
to work when printing to another printer that we have but
nothing seems to happen when the program prints
to the card printer. I tried playing around and
noticed that an exception gets thrown when
trying to get default values from the printer.
printer driver url:
http://www.eltroncards.com/drivers/downloads/winnt/p420_wnt_
0206.exe
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.ArrayIndexOutOfBoundsException
at sun.print.Win32PrintService.getDefaultAttributeValue
(Win32PrintService.java:786)
at sun.print.Win32PrintService.getSupportedAttributeValues
(Win32PrintService.java:1049)
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.print.*;
import javax.print.event.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
public class test {
public test() {
PrintService printer =
PrintServiceLookup.lookupDefaultPrintService();
Class[] categories = printer.getSupportedAttributeCategories();
for (int i=0; i<categories.length; i++)
{
System.out.print("Class "+categories[i]);
System.out.print(' ');
Object value = printer.getSupportedAttributeValues
(categories[i], null, null);
if (value.getClass().isArray())
{
Object[] v = (Object[])value;
for (int j=0; j<v.length; j++)
{
if (j > 0)
System.out.print(", ");
System.out.print(v[j]);
}
}
else
System.out.print(value);
System.out.println();
}
}
public static void main(String[] args) {
test test1 = new test();
}
}
---------- END SOURCE ----------
(Review ID: 145232)
======================================================================