![]() |
![]() |
Java Multithreading | |
Creating a Thread | |
Thread Life Cycle | |
Thread Exceptions | |
Thread Synchronization |
Intro. to Graphics class | |
Drawing - Lines , Rectangles | |
Drawing - Circles and Ellipse | |
Drawing - Arcs | |
Drawing - Polygons | |
Drawing - Bar Charts |
Java Programs | |
Java Keywords Dictionary | |
Java Interview Questions |
The second way of displaying the applet is on Webpage using browser.
To run the java applet, the web page that references that applet is required HTML Hyper Text Markup Language.
<html> <head> <title>Title Text </title> </head> <body> Actual html files to display on webpage. </body> </html>
Save the file using filename with .html extension and open that saved file.
You will display an output as Actual html files to display on webpage. in browser.
This section holds comments which are never displayed on the webpage. Web browser ignores the text enclosed within < ! tag.
The head section is enclosed within starting <head > and ending with</head>
Body section contains the entire information about web page. The applet is written inside the body section.
import java.awt.*; import java.applet.*; public class AppletProgram extends Applet { public void paint(Graphics g) { g.drawString("Hello Applet", 15, 140); } }
Compile the applet code using javac AppletProgram.java
This will create an .class file link this .class file to html code.
<html> <head> <title>Applet Test </title> </head> <body> <applet code="AppletProgram.class" width="500" height="500"></applet> </body> </html>
Open the .html file to see below output
No Output - If you don't see any output in html page then update your browser or enable the java in settings. |