• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AccessControlException When Capture screen with Applet

 
I Gusti Putu Anom Abadi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo All,
I Need some help,
I am creating an applet to capture the screen,
when it is as a class with main function, it working,
but when it is as applet, this will throw an exception
java.security.AccessControlException: access denied (java.awt.AWTPermission createRobot)
I read some article, that applet very secure, it can't read local file system.
try
{
SecurityManager security = System.getSecurityManager();
if (security != null)
{
try
{
AWTPermission Aperm = new AWTPermission("createRobot");
security.checkPermission(Aperm);
BufferedImage ScImage = (new Robot()).createScreenCapture(new Rectangle(0,0,800,600));
......
...
}catch(AccessControlException xc)
{
System.out.println("AwtPermission -> Create Robot");
System.out.println(xc.toString());
}finally
{
//System.exit(0);
}
}catch(Exception ef)
{
System.out.println("anom"+ef.toString());
}
is that line correct to get a security access ..?
can anyone tell me how to handle this security, please
Thank in advance,
Best Regards,
Anom
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic