Simple applet program                        1
ObjectivesOn completion of this period, you will be able to  learn• Simple Applet program                                 ...
RecapIn the last class we have studied about the  Basics of Applet• There exist two types of Java programs  • Java Applica...
Simple AppletThe following program shows how to write a simple  appletimport java.awt.*;import java.applet.*;public class ...
Simple Applet      contd..• It has two import statements namely  • import java.awt.*;  • import java.applet.*;• First stat...
Simple Applet          contd..• Every applet that you create must be a subclass  of Applet• The next line in the program d...
Simple Applet         contd..• Inside SimpleApplet, paint( ) is defined• This method is defined by the AWT and must be  ov...
Simple Applet              contd..• Inside paint( ) is a call to drawString( ), which is  a member of the Graphics class• ...
Simple Applet          contd..• In window, the upper-left corner is at location  0,0• Call to drawString( ) in the applet ...
Summary   In this class, you have learnt• We have learned how to write a simple applet  program• We learned the importance...
Frequently Asked Questions• Write an applet program which draws a simple  string called “Hello Applet”                    ...
Quiz1. Applets interact with the user through ----   1. AWT   2. console   3. command line   4. none                      ...
Quiz2. Applet class must be declared as public   – True   – False                                             13
Upcoming SlideShare
Loading in …5
×

Simple applet progra.54

387 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
387
On SlideShare
0
From Embeds
0
Number of Embeds
22
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Simple applet progra.54

  1. 1. Simple applet program 1
  2. 2. ObjectivesOn completion of this period, you will be able to learn• Simple Applet program 2
  3. 3. RecapIn the last class we have studied about the Basics of Applet• There exist two types of Java programs • Java Application which is a console based program • Applet which is a web enabled Java program for Internet applications purpose 3
  4. 4. Simple AppletThe following program shows how to write a simple appletimport java.awt.*;import java.applet.*;public class SimpleApplet extends Applet { public void paint(Graphics g) { g.drawString(“Hello Applet", 20, 20); }} 4
  5. 5. Simple Applet contd..• It has two import statements namely • import java.awt.*; • import java.applet.*;• First statement imports the Abstract Windowing Toolkit (AWT) classes• Applets interact with the user through the AWT, not through the console-based I/O classes.• Second import statement imports the Applet class from the applet package 5
  6. 6. Simple Applet contd..• Every applet that you create must be a subclass of Applet• The next line in the program declares the class SimpleApplet• This class must be declared as public, because it will be accessed by code that is outside the program 6
  7. 7. Simple Applet contd..• Inside SimpleApplet, paint( ) is defined• This method is defined by the AWT and must be overridden by the applet• paint( ) is called each time that the applet must redisplay its output 7
  8. 8. Simple Applet contd..• Inside paint( ) is a call to drawString( ), which is a member of the Graphics class• General form is: • void drawString(String message, int x, int y) where, message is the string to be output beginning at x, y 8
  9. 9. Simple Applet contd..• In window, the upper-left corner is at location 0,0• Call to drawString( ) in the applet causes the message• “Hello Applet” to be displayed at location 20,20 9
  10. 10. Summary In this class, you have learnt• We have learned how to write a simple applet program• We learned the importance of each statement in the Applet program 10
  11. 11. Frequently Asked Questions• Write an applet program which draws a simple string called “Hello Applet” 11
  12. 12. Quiz1. Applets interact with the user through ---- 1. AWT 2. console 3. command line 4. none 12
  13. 13. Quiz2. Applet class must be declared as public – True – False 13

×