Your SlideShare is downloading. ×
0
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Simple applet progra.54
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Simple applet progra.54

213

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
213
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Simple applet program 1
  • 2. ObjectivesOn completion of this period, you will be able to learn• Simple Applet program 2
  • 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. 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. 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. 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. 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. 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. 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. 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. Frequently Asked Questions• Write an applet program which draws a simple string called “Hello Applet” 11
  • 12. Quiz1. Applets interact with the user through ---- 1. AWT 2. console 3. command line 4. none 12
  • 13. Quiz2. Applet class must be declared as public – True – False 13

×