FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Windows XP 2002 SP3
EXTRA RELEVANT SYSTEM CONFIGURATION :
Sony Vaio VGN-FS415M
HP Laserjet 1015 on Local network.
A DESCRIPTION OF THE PROBLEM :
The code :
comp.getGraphics().setFont(new Font(Font.SERIF,Font.PLAIN,18));
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
PrintServiceAttributeSet psas= ps.getAttributes();
String psasString = psas.toString();
Attribute[] psasArray = psas.toArray();
try {
comp.print(new MessageFormat(PrintMessage2+" "+PrintMessage1),new MessageFormat(PrintMessage3));
JOptionPane.showMessageDialog(null,"essai","Attention test d'impression en cours !",JOptionPane.INFORMATION_MESSAGE);
} catch (PrinterException ex1) {
// traitement de l'exception
JOptionPane.showMessageDialog(null,ex1.getMessage(),resources.getString("Print_Problem_Message"),JOptionPane.WARNING_MESSAGE);
} catch (SecurityException ex2) {
JOptionPane.showMessageDialog(null,ex2.getMessage(),resources.getString("Print_Problem_Message"),JOptionPane.WARNING_MESSAGE);
}
The result :
When the computer is connected to the local network the print dialog and the JOptionPane are displayed.
When the computer is not connected (connector unplug) neither the JOptionPane in the catch PrinterException nor the JOptionPane in the SecurityException are displayed.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.security.PrivilegedActionException: java.awt.print.PrinterException: Invalid name of PrintService.
at java.security.AccessController.doPrivileged(Native Method)
at sun.print.RasterPrinterJob.printDialog(Unknown Source)
at javax.swing.text.JTextComponent.print(Unknown Source)
at javax.swing.text.JTextComponent.print(Unknown Source)
at ScientificPad$printAction.actionPerformed(ScientificPad.java:1791)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.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 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.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.awt.print.PrinterException: Invalid name of PrintService.
at sun.awt.windows.WPrinterJob.setNativePrintService(Native Method)
at sun.awt.windows.WPrinterJob.getPrintService(Unknown Source)
at sun.print.RasterPrinterJob$3.run(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.