This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PrinterJob hangs in applet when called from javascript.  RSS feed

Mark McNair
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!