jQuery in Action, 3rd edition
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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

PrinterJob hangs in applet when called from javascript.

Mark McNair

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");

public void updateText(String aText)

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");
java.awt.print.PrinterJob printJob = java.awt.print.PrinterJob.
if (printJob.printDialog()) {
System.out.println("print me ");
} else
System.out.println(" dont print me ");
System.out.println("hello Manoj");
I agree. Here's the link: http://aspose.com/file-tools
subject: PrinterJob hangs in applet when called from javascript.
It's not a secret anymore!