Check the stack trace:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "exitVM.0")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:560)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkExit(SecurityManager.java:761)
at javax.swing.JFrame.setDefaultCloseOperation(JFrame.java:394)
at FullScreenWindow.<init>(FullScreenWindow.java:72)
at FullScreenWorld.createFullScreenWindow(FullScreenWorld.java:165)
at FullScreenWorld.<init>(FullScreenWorld.java:115)
at ExampleWorld.<init>(ExampleWorld.java:13)
at InitialisingWorld.act(InitialisingWorld.java:32)
at greenfoot.core.Simulation.actWorld(Simulation.java:574)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:509)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
It looks like you're setting the close operation for the frame to "exit". An applet isn't allowed to exit the VM, so this causes an exception.
Oh that sounds like it's pretty easy to fix.
Thank you very much davmac.
But I still got one question: Where can I get this stack trace?
I never find it when I run a jar file or a applet on the webside.
I now could fix some problems with the stack trace but now I again got a problem where I need help.
The stack trace says:
java.lang.NoClassDefFoundError: FullScreenWorld$1CursorDisappear
at FullScreenWorld.manageCursor(FullScreenWorld.java:283)
at FullScreenWorld.<init>(FullScreenWorld.java:117)
at ExampleWorld.<init>(ExampleWorld.java:13)
at InitialisingWorld.act(InitialisingWorld.java:32)
at greenfoot.core.Simulation.actWorld(Simulation.java:574)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:509)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
Caused by: java.lang.ClassNotFoundException: FullScreenWorld$1CursorDisappear
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 8 more
The problem occours because the class is not found. The class that is not found is declared locally.
So my question: Are local classes not uploaded to the webside? Because offline everything works fine.
The local class is in the jar file, but it is incorrectly named as "FullScreenWorld$1cursorDisappear.class" (with a lower-case 'c' in 'cursor'). I guess you're on a system with a case-insensitive file system; you probably create the class initially with the wrong name, and then changed it.
To fix the problem, just rename the file within your scenario manually (or delete it and re-compile) before exporting again.
Ok I'll try that.
Thanks davmac.
The next problem:
java.security.AccessControlException: access denied ("java.awt.AWTPermission" "watchMousePointer")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
at java.awt.MouseInfo.getPointerInfo(Unknown Source)
at FullScreenMouseInfo.<init>(FullScreenMouseInfo.java:21)
at FullScreenWindow.getMouseInfo(FullScreenWindow.java:158)
at FullScreenWorld$1CursorDisappear.<init>(FullScreenWorld.java:256)
at FullScreenWorld.manageCursor(FullScreenWorld.java:283)
at FullScreenWorld.<init>(FullScreenWorld.java:117)
at ExampleWorld.<init>(ExampleWorld.java:13)
at InitialisingWorld.act(InitialisingWorld.java:32)
at greenfoot.core.Simulation.actWorld(Simulation.java:574)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:509)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
Sounds like I'm not allowed to check the mouse state.
Any ideas how to fix this?
I'm not sure what you mean by "check the mouse state" nor why you're doing that. Can't you just add mouse listeners to the window?
I am just using mouseListeners.
The stack trace says that there is a problem while creating a CursorDisappear object.
This object has a field which is a FullScreenMouseInfo object.
And while initialising this object there seems to be an access problem.
The FullScreenMouseInfo object is only a interpreter for mouseEvent objects.
A mouseListener sends the MouseEvents to the fullscreenwindow where they are interpreted with a FullScreenMouseInfo object.
So I am just using a mouseListener. I don't get why this isn't working.
Because again offline everything works perfectly.
The stack trace shows that you are calling "java.awt.MouseInfo.getPointerInfo()". This is not the same as using a mouse listener. The events passed to the mouse listener contain the mouse pointer location and button state.
Oh I forgot to delete this.
I was just trying to use this method and forgot that I found a better way.
@darkmist255 Thanks. It was realy not easy but the result is nice.