java - How to close frame within applet? -


Friends to close the frame inside applet ... my program is working, but the problem is trying The frame that will be made is not locked in the applet ... What should I do ... This gives me the exception when closing the frame window:

  c: \ jdk1. 6.0 \ bin> appletviewer me.java Exception in thread "AWT-EventQueue-1" java.security.AccessControlException: java.security.AccessControlContext.checkPermission (AccessControlContext.java:323) java.security.AccessController.checkPermission And denied (java.lang.RuntimePermission exitVM.0) Access (AccessController .java: 546)   

This is my code:

  import java. Awt. *; Import java.applet *; Import java.awt.event. *; / * & LT; Applet code = "me.class" height = 500 width = 500 & gt; & Lt; / Applet & gt; * Width from frame / string {string msg; From the public () {msg = "This is the frame"; AddWindowListener (new window adapter) {Public Zero Window Closure (WindowEvent e) {System.exit (0);}}); } Public Zero Color (Graphics G) {g.drawString (msg, 10,100); }} Public square I expand the applet (public zero init () {from s1 = new to ()) s1.setSize (400,400); S1.setVisible (true); S1.setTitle ("Java Gamer"); } Public Zero Color (Graphics G) {g.drawString ("This is Applet", 10,100); }}    

  System.exit (0);   

Applet is not allowed by sandbox, Even if the applet is completely reliable.

But to improve it, the stand-app app ( frame / JFrame ) & amp; Use it with a link / button on a web page. JWS works on Windows, OS X & amp; * Nix. Then the frame can call System.exit (n) at any security level.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -