More Related Content


Applet programming

  2. OVERVIEW  Applets  Ways for running an applet  Steps to iterate through applet development  Methods: life cycle of an applet  Event handling 2
  3. I. APPLETS  Small applications accessed on Internet server, transported over Internet, automatically installed and run as part of a Web document  must be a subclass of the java.applet.Applet class Simple applet overview- Note the following considerations for this program- oTwo import statements used: oClass SimpleApplet is declared public to be accessed by code outside the program
  4. APPLETS (CONTINUED)  Class SimpleApplet is also declared public  paint( ) is declared inside SimpleApplet defined by the AWT  paint( ) is called- o Each time when applet must redisplay output o When applet begins execution  A call to drawString( ) inside paint( ), is a member of Graphics class that outputs a string beginning at the specified X, Y location. 4
  5. II. WAYS FOR RUNNING AN APPLET Execution within a Java compatible Web browser Using an applet viewer A. Execution via Web browser- <applet code= “SimpleApplet” width=200 height=60> </applet> B. Via an applet viewer- o Applet executed in a window via Applet viewer using Command prompt Example: if preceeding HTML file is called Run.html, SimpleApplet can run by the following code- C:>appletviewer Run o Fastest and easiest way to test Applet 5
  6. III. STEPS TO ITERATE THROUGH APPLET DEVELOPMENT Edit a Java source file Compile your program Execute applet viewer specifying name of applet’s source file 6
  7. IV. METHODS: LIFE CYCLE OF AN APPLET A. Init B. Start C. Stop D. Destroy E. Paint 7
  8. VI. EVENT HANDLING  Mechanism used to handle events  Key events in java: o ActionEvent o ItemEvent o TextEvent o WindowEvent o KeyEvent 8
  9. CONCLUSION Applets are one of the beauty under java programming language which provide means to distribute interesting dynamic interactive application over world wide web 9
  10. Thank you. 10