Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
In the init method this applet gets a reference to the browser it's running in.
When the button is clicked, we get the text from the TextField and use it to create a java.net.URL object :
If the string contains a valid protocol, like http, the URL object is created ....
and the program could continue by asking the browser to show the document that the URL refers to in the same window that the applet and its HTML are in .
This would mean that the contents of the window/frame that this applet is in, would be replaced by the requested HTML-document and the APPLET would be TERMINATED.
Since this is not the case in this example, the requested HTML document is shown in a NEW window, called 'fraym'. If a window or HTML FRAME by the name given already exists, then that is used as target destination.
Many menu applets are implemented this way.
If a URL instance can NOT be constructed, the program skips the showDocument call and continues with the catch of a MalformedURLException .
Instead of "_self" or a name of a window/frame, you can use :
_top the browser's top-level window.
_parent the applet frame's parent frame/window.
Another protocol, file, makes it possible to test without an internet connection, for example :
Same result if you omit the 2nd argument