File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes PrinterJob hangs in applet when called from javascript. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "PrinterJob hangs in applet when called from javascript." Watch "PrinterJob hangs in applet when called from javascript." New topic
Author

PrinterJob hangs in applet when called from javascript.

Mark McNair
Greenhorn

Joined: Sep 30, 2003
Posts: 3
I have javascript calling a method inside an applet in the HTML. This method
accesses the PrinterJob class to get default client printers. However a warning ( greyed out ) comes on IE and the browser and console hangs !! Applet code is below.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.print.*;
import java.beans.*;
import javax.swing.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class PrintApplet extends JApplet {
private boolean isStandalone = false;

TextField field = new TextField();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}

//Initialize the applet
public void init() {
field.setText("Hello Nair");
this.getContentPane().add(field);
validate();
}

public void updateText(String aText)
{
field.setText(aText);
validate();
}

public void paint(Graphics g) {

}

//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}

public void callMeSucker()
{
updateText("from sucker");
RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
java.awt.print.PrinterJob printJob = java.awt.print.PrinterJob.
getPrinterJob();
printJob.setCopies(1);
if (printJob.printDialog()) {
System.out.println("print me ");
} else
{
System.out.println(" dont print me ");
}
System.out.println("hello Manoj");
RepaintManager.currentManager(this).setDoubleBufferingEnabled(true);
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PrinterJob hangs in applet when called from javascript.