• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PrinterJob hangs in applet when called from javascript.

 
Mark McNair
Greenhorn
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");
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);
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic