1 / 10

Applets

Applets. Applets. Design of Applets. Design of Applets. Sun wrote Java to be executable within a hosting application browser The applications are applets. An applet is downloaded to the local client application and run on the local java-enabled machine

ryder
Télécharger la présentation

Applets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Applets

  2. Applets • Design of Applets

  3. Design of Applets • Sun wrote Java to be executable within a hosting application • browser • The applications are applets. • An applet isdownloaded to the local client application and run on the local java-enabled machine • All ordinary capability except file output and database input or output is easily available

  4. Design of Applets • An Applet is run inside of another application • Browser • AppletViewer • The programmer adds panels with their controls to browser’s content panel (the web page)

  5. Design of Applets • There are five major methods in an Applet: • init () called when Applet starts • start () called when page is displayed • stop () called when user exits • destroy () called when resources are lost • paint () called when Applet is refreshed

  6. Design of Applets • Sample code:public class Program4 extends JApplet • { • public void init () • { • getContentPane ( ).add(myPanel); • } • } • Where myPanel is the one of the panels containing controls

  7. Design of Applets • Design of Hosting Web Page (use of Applet tag) • <body> • <applet code=myservlets.AdderApplet.class width=550 height=400> • <param name=host value= • "http://localhost:8080/user002/servlet/myservlets.AdderServlet"> • </applet> • </body> • Where host is an argument sent to the Applet from the web page

  8. GUI Applications • Using a frame: public class Example extends JFrame { public Example ( ) { getContentPane( ).add(myPanel); } public static void main (String args [ ]) { Example example = new Example (“Example”); example.setTitle (aTitle); example.setSize (300, 250); example.setDefaultCloseOperation (3); example.setVisible(true); } • }

  9. GUI Application as Applet • Init and handle events public class Example extends JApplet { public void init ( ) { getContentPane( ).add(myPanel); setTitle (aTitle); setSize (300, 250); setDefaultCloseOperation (3); setVisible(true); } • See ConvertTemperatures applet, and note change from application

  10. Summary • Applets are a window system • One can also place windows in a frame and use them in an application • Applets significantly bring web-based applications to life by moving the work to the client machine • Error checking can be decentralized from the server to the clients

More Related