FULL PRODUCT VERSION :
Occurs with both 6.0 (mustang) and
Java 1.6.0_01 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
HP Color LaserJet 5500
A DESCRIPTION OF THE PROBLEM :
This appears to be the same bug as 6174596, but that is marked fixed in Mustang. I am still seeing the problem in both 6.0 and 6.0_01.
When HP Color LaserJet 5500 is set to be my default printer, I get the following exception when I first bring up the print dialog (using 1.4 printing API):
java.lang.ArrayIndexOutOfBoundsException: 26
at sun.print.Win32PrintService.getMediaTrays(Unknown Source)
at sun.print.Win32PrintService.getSupportedAttributeValues(Unknown Source)
at sun.print.ServiceDialog$MediaPanel.updateInfo(Unknown Source)
at sun.print.ServiceDialog$PageSetupPanel.updateInfo(Unknown Source)
at sun.print.ServiceDialog.updatePanels(Unknown Source)
at sun.print.ServiceDialog.access$1300(Unknown Source)
at sun.print.ServiceDialog$PrintServicePanel.popupMenuWillBecomeInvisible(Unknown Source)
at javax.swing.JComboBox.firePopupMenuWillBecomeInvisible(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup.firePopupMenuWillBecomeInvisible(Unknown Source)
at javax.swing.JPopupMenu.setVisible(Unknown Source)
at javax.swing.JPopupMenu.menuSelectionChanged(Unknown Source)
at javax.swing.MenuSelectionManager.setSelectedPath(Unknown Source)
at javax.swing.MenuSelectionManager.clearSelectedPath(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup.hide(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI.setPopupVisible(Unknown Source)
at javax.swing.JComboBox.setPopupVisible(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.Dialog$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set HP Color LaserJet 5500 to be your system's default printer
Run a test application that brings up the 1.4 print dialog.
Exception is thrown. Another way to reproduce this is to have a different default printer and then select the HP printer from the print dialog dropdown. The exception is thrown at that point.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect no exception.
ACTUAL -
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 26
at sun.print.Win32PrintService.getMediaTrays(Unknown Source)
at sun.print.Win32PrintService.getSupportedAttributeValues(Unknown Source)
at sun.print.ServiceDialog$MediaPanel.updateInfo(Unknown Source)
at sun.print.ServiceDialog$PageSetupPanel.updateInfo(Unknown Source)
at sun.print.ServiceDialog.updatePanels(Unknown Source)
at sun.print.ServiceDialog.access$1300(Unknown Source)
at sun.print.ServiceDialog$PrintServicePanel.popupMenuWillBecomeInvisible(Unknown Source)
at javax.swing.JComboBox.firePopupMenuWillBecomeInvisible(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup.firePopupMenuWillBecomeInvisible(Unknown Source)
at javax.swing.JPopupMenu.setVisible(Unknown Source)
at javax.swing.JPopupMenu.menuSelectionChanged(Unknown Source)
at javax.swing.MenuSelectionManager.setSelectedPath(Unknown Source)
at javax.swing.MenuSelectionManager.clearSelectedPath(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup.hide(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI.setPopupVisible(Unknown Source)
at javax.swing.JComboBox.setPopupVisible(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See above
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.ServiceUI;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import java.awt.*;
import java.awt.print.Printable;
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
public class PrintTest{
private JFrame fFrame;
private MyTextArea fTextArea;
public PrintTest(){
//bring up a 1.4 print dialog for a text area.
fFrame = new JFrame("Text Area");
fTextArea = new MyTextArea("foo bar test\n" +
"foo bar test\n" +
"test test test");
fFrame.getContentPane().add(fTextArea);
fFrame.setSize(200, 200);
fFrame.setVisible(true);
print();
}
public void print(){
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintService defaultService =
PrintServiceLookup.lookupDefaultPrintService();
final PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
PrintService[] printService = // using pras above causes problems-- no printers returned
PrintServiceLookup.lookupPrintServices(flavor, new HashPrintRequestAttributeSet());
Point location = fFrame.getLocationOnScreen();
ServiceUI.printDialog(null, location.x + 100, location.y + 100,
printService, defaultService, flavor, pras);
}
public class MyTextArea extends JTextArea implements Printable{
public MyTextArea(String text){
super(text);
}
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException{
return -1;
}
}
public static void main(String[] args){
new PrintTest();
}
}
---------- END SOURCE ----------