Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Caught an exception -- com.ms.security.SecurityExceptionEx[......]

Status
Not open for further replies.

cklim

Programmer
Jul 15, 2002
2
US
I have written an application to print an applet. It compiled but when I clicked the button print, there is errors showing in the Java Console saying:

com.ms.security.SecurityExceptionEx[PrintApplet.printComponents]
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkPrintJobAccess
at com/ms/awt/WToolkit.getPrintJob
at PrintApplet.printComponents
at PrintApplet$1.actionPerformed
at java/awt/Button.processActionEvent
at java/awt/Button.processEvent
at java/awt/Component.dispatchEventImpl
at java/awt/Component.dispatchEvent
at java/awt/EventDispatchThread.run
Exception occurred during event dispatching:
com.ms.security.SecurityExceptionEx[PrintApplet.printComponents]
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkPrintJobAccess
at com/ms/awt/WToolkit.getPrintJob
at PrintApplet.printComponents
at PrintApplet$1.actionPerformed
at java/awt/Button.processActionEvent
at java/awt/Button.processEvent
at java/awt/Component.dispatchEventImpl
at java/awt/Component.dispatchEvent
at java/awt/EventDispatchThread.run

This is my code of printing applet(actually is from a book):

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.Properties;

public class PrintApplet extends Applet
{
Button printButton = new Button("print...");

static Frame getFrame(Component c)
{
while((c = c.getParent())!=null)
{
if(c instanceof Frame)
return (Frame) c;

}
return null;
}

static void printComponents(Component c)
{
Toolkit tk = Toolkit.getDefaultToolkit();
Frame frame = getFrame(c);
Properties props = new Properties();

props.put("awt.print.printer", "durango");
props.put("awt.print.numCopies", "2");

if(tk != null)
{
String name = c.getName() + "print job";
PrintJob pj = tk.getPrintJob(frame, name, props);

if(pj != null)
{
Graphics pg = pj.getGraphics();

if(pg != null)
{
try{
c.printAll(pg);
}
finally
{
pg.dispose();
}
}
pj.end();
}
System.out.println(props);
}
}
public void init()
{
add(printButton);
add(new Label ("print this label"));
add(new TextField("print this textfield"));
add(new TextArea(10,20));

printButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
printComponents(PrintApplet.this);
}
});
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top