What is the code so that nothing can leave the applet?

Sorry if this is not in the right section but thanks!

By what I mean also, if you don't understand, is I mean how can you make it so that...