Presentation is loading. Please wait.

Presentation is loading. Please wait.

Applets.

Similar presentations


Presentation on theme: "Applets."— 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 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 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)
11/30/2018 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= " </applet> </body> Where host is an argument sent to the Applet from the web page applets

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


Download ppt "Applets."

Similar presentations


Ads by Google