Presentation Description

BCA 5th sem


Presentation Transcript




2 Introduction We can write two kinds of program in JAVA they are APPLICATION BASED APPLET BASED The application based programs are the programs which are used in the places such as super markets, hospitals etc. The applet based program is used for the development of Graphics .

Slide 3:

APPLETS APPLET is a small application embedded in HTML page, which is accessed & transported over the Internet , automatically installed into client machines and run as part of web page. Applet are great for creating dynamic & interactive web applications . Applet is a self executing program .

Slide 4:

Init() : initializes applet before loading. Start(): starts execution of applet Paint(): graphics created Stop(): stops any operation Destroy(): applet completes execution To create applet , Applet class from java. applet package should be imported so tht they are automatically run by any applet program Applet Life Cycle

Slide 5:

The init() method The init method is invoked after the applet is created or recreated. A subclass of Applet should overrides this method if the subclass has an initialization to perform. Usually includes creating new thread, loading images, setting up GUI components

Slide 6:

Start() method The start method is invoked after the init method. Called whenever the applet become active A subclass of Applet overrides this method if it has any operation that needs to be performed whenever the webpage is visited. An applet with animation might use the start method to resume animation

Slide 7:

Stop() method The stop method is the opposite of the start method. Is invoked when the user leave the page. A subclass of Applet overrides this method if it has any operation that needs to be performed When the user leaves the page, any threads that applet has started but not completed will continue to run. You should override the stop method to suspend the running threads so that the applet does not take up system resources when it is inactive

Slide 8:

Destroy() method The destroy() method is invoked when the browser exits normally to inform the applet that is no longer needed and should release any resources it has allocated. The stop method is always called before the destroy method A subclass of Applet overrides this method if it has any operation that needs to be performed before it is destroyed Usually you won’t need to override this method unless you wish to release specific resources, such as threads that the applet created

Slide 9:

import java.applet.Applet; import java.awt.*; public class Drawing extends Applet { public void paint(Graphics g) { } } g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); g.drawOval(x, y, width, height); g.fillOval(x, y, width, height); g.drawString (“Hello”, 20, 20); Hello A SIMPLE APPLET Use paint () method Thank you