






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This document from docsity.com covers the basics of applets and graphics in java, including creating applets in jbuilder7, the applet life cycle, and exception handling. It includes code examples for creating a simple applet that displays 'hello world' and changes the font color.
Typology: Slides
1 / 38
This page cannot be seen from the preview
Don't miss anything!
java.applet.Applet
import java.applet.*;
import java.awt.*;
public class HelloApplet{ }
public class helloApplet extends Applet{ }
Helloapplet..cont..
public class HelloApplet extends Applet{
public void paint(Graphics g){ } }
public class HelloApplet extends Applet{
public void paint(Graphics g){ g.drawString(“Hello World”,25,25); } }
import java.awt.; import java.applet.;
public class HelloWorld extends Applet{ public void paing(Graphics g){ g.drawString(“Hello World”,25,25); } }
<applet codebase=“.” code=“HelloWorld.class” height= width=100 >
Applet are to be executed in a web browser
Each web browser require specific method to be in an applet There are numerious (one book say about 200 ) methods required by the browser java.applet.Applet have the core functionality required by the browser
Inherited from the parent Empty implementation Child creates its own version according to requirements
A java class for rendering graphics on the screen Browser provides the implementation according to the local system
public void paint(Graphics g){ g.setColor(Color.green); g.drawString("The changed world",25,25); }
Can be uses to define colors Color c=new Color(12,34,20); Contains predefined colors Color.red Color.green
public void paint(Graphics g){ Image img=getImage(getCodeBase(),"test.gif"); g.drawImage(img,40,40,50,50,this); }
An abstract class in awt package Provide image manipulation method such as controlling height width etc..
A method provided by Applet parent class Use to load images from local system and servers as well
Returns a url pointing to the location where the class file is saved
Returns a url pointing to the location where the html file of the applet is saved
init() The first method called by the browser Can be used to do some initialization work start() Called by the browser when init() method has finished execution Called to restart the applet when it is stopped by the user or browser paint() The paint method is called after start to draw graphics on the screen re-called each time when there is something to draw on the screen or there is some changing in the drawing If the applet has GUI components it follow a different path Stop() Called by the browser when the applet is not being displayed This method stops the execution of the applet thread destroy() Called by the browser just before destroying the applet This method can be used to do some wrap up work
select new Select applet Click OK
Write your package name Write class name for the applet Select one of the two base file Choose Applet If checked unchecked generate standard methods Used to create all standard method e.g. init ,start stop… Click next
Choose a file name for your html file Choose a title Choose height and width parameter values for your applet You can ignore hspace and vspace Click next
Ignore it and click finish