I have no idea what you're asking. What are you trying to prevent from "leaving the applet"? What exactly does that even mean?
By the way, this is the completely wrong forum for this question. I'll move the thread for you.
--- Update ---
This thread has been cross posted here:
http://www.java-forums.org/java-applets/72663-how-do-you-add-barrier-around-your-applet-so-nothing-goes-out-applet.html
Although cross posting is allowed,
for everyone's benefit, please read:
Java Programming Forums Cross Posting Rules
The Problems With Cross Posting