OpenWebPageApplet.html
The browser scans the applet> element and recognizes that it needs to launch a Java applet when you load this HTML in a browser (that supports Java applets, with the relevant configurations in place). The “OpenWebPageApplet.class” file, which contains the bytecode for the applet, will then be searched for by the browser. This bytecode will be executed by the Java Virtual Machine (JVM), and the applet will operate in the area enclosed by the width and height (in this case, 800×300 pixels). When the applet starts, the init() method is invoked, which configures the event listeners and user interface components (such as buttons and text fields).
The final OpenWebPageApplet.html file will look like this:
HTML
<!DOCTYPE html> < html > < head > < title >Open a link using Applet</ title > </ head > < body > < applet code = "OpenWebPageApplet.class" width = "800" height = "300" ></ applet > </ body > </ html > |
How to Open a Link in a New Window Using Applet?
A Java applet is a little application created in the Java programming language and run on a web browser while embedded in an HTML page. In essence, it’s a method for introducing Java’s “write once, run anywhere” feature to the world of web browsers.
Components and Organization
- Applets are subclasses of the ‘java.applet.Applet’ class.
- For their graphical user interface, they can use either the AWT (Abstract Window Toolkit) or Swing frameworks, however, AWT has a smaller environmental impact and was previously more popular.