Mod 5 Java
Mod 5 Java
<html>
<body>
<applet code=”MyApplet” width=200 height=200></applet>
</body>
</html>
Life Cycle of an Applet Init()
Born
start()
Running
paint()
Stop()
Start()
Idle
destroy()
Dead
Applet ends
• Import java.applet.*;
• Import java.awt.*;
• /*
• <applet code=Applet1 width=200 height=150>
• </applet> */
• Public class Applet1 extends Applet
• {
• public void paint(Graphics g)
• {
• g.drawstring(“Welcome”,20,40);
• }
• }
• setBackground(Color.green) & getBackground()
• setForeground(Color.red) & getForeground()
• String getAppletInfo() – returns string that describes applet.
• URL getCodeBase() – return URL associated with the applet.
• getParameter(string pname) – returns the string associated with
the parameter pname.
• Boolean isAlive() – returns true if the applet has been started.
• Void resize(int width, int height) – resizes the window according to
the width and height.
• Void showStatus(String s) – displays the strings in the status
window of the browser.
Passing Parameters to Applet
jdbc:mysql://hostname/
MySQL com.mysql.jdbc.Driver
databaseName
oracle.jdbc.driver.Oracle jdbc:oracle:thin:@hostname:port
ORACLE
Driver Number:databaseName
COM.ibm.db2.jdbc.net.D jdbc:db2:hostname:port
DB2
B2Driver Number/databaseName