Java printing not working after SP2 update

C

Christina Ahrens

I am experiencing a problem where an extremely simple Java
printing application will not work after updating to
Service Pack 2. The test program (hangs before printing
dialog should be displayed) is below. Does anyone know
about this problem? "File and Printer Sharing" is
selected under the Windows Firewall settings.

Thanks,

Christina

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();
}
}
 
C

Christina Ahrens

Just a clarification-- the problem occurs only in a
network situation. If I log into "This Machine" instead
of "Network", then printing will work.

Thanks,

Christina
 
Top