Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Applets. 2 Design of Applets 3 Sun wrote Java to be executable within a hosting application browser The applications are applets. An applet is downloaded.

Similar presentations


Presentation on theme: "1 Applets. 2 Design of Applets 3 Sun wrote Java to be executable within a hosting application browser The applications are applets. An applet is downloaded."— Presentation transcript:

1 1 Applets

2 2 Design of Applets

3 3 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 All ordinary capability except file output and database input or output is easily available

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

8 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 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 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


Download ppt "1 Applets. 2 Design of Applets 3 Sun wrote Java to be executable within a hosting application browser The applications are applets. An applet is downloaded."

Similar presentations


Ads by Google