0% found this document useful (0 votes)
16 views39 pages

Apple Ts

applet in oops

Uploaded by

Sameer Kothare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
16 views39 pages

Apple Ts

applet in oops

Uploaded by

Sameer Kothare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 39
which can bea web From Component das an ad handle eet, [Every applet is implemented by creat Applet class, Following diagram shows thei ierarehy of Applet class ‘An applet class extends from AWT Panel extends AWT Container clas | yet Panel that is embedded in a specialized compo 2. Remote 209) fr use on interact, te vod aicins 2 Example CODEBASE = http :/ www.Serve.com/applets ut. For example applets making it available their computer. swer or Javacenabl 1g are the steps applet are tag into the Web pas Subclass of an Applet example: ‘The extends keyword spec subclass of the Applet elas. AS he subclass of the super elas® Aapie sutomatically inherits all ie B= Designing a | Running the Applet of java file) Program 5.2: The Hello J In comments. Java Applet with applet 189 nds Applet public wid paint (Graphics g ) Vaal drawstring (‘Hello Java", 11, 110); |/*PLET> tag in full form is shows mare bracket & (] are optional. pee = alignment jet will appeat [ CODEBASE = codepass-url ] RIGHT,» MIDDLE: CODE = AppletfileName.class as TEXTTOP, BASELINE: ALT = alternate_text ] |‘ HSPACE = pixel8 { ? wot eee ee [NAME = applet_instance_name ] WIDTH = pixels HEIGHT = pixels the amount aa leave surrounding “ Welcome To Java Applets programming |

program 5.4: Program tc Applet. welcome Tova rosea: message = ic void paint( Graphics ) c.rawSting(nessage 0a 4 5.4.1 Parameter Passing to Applet or PARAM Tag Q. Write procedure to accept parameters fo al Suing messager mom) pt vis init) ©. Describe the procedure for passing parameters Code to an applet. * User defined parameters can be passed 6 pale .g Tag. Each tag, in HTML document. i is to parse these 2. Provide code in the applet Output ad Td be Cal HelloNIDH! Lengin= 5 plet | 3 Methods used in AP | §1 updated method whieh repaint) specifies the region that ed. The upper left coordinates are and top. The width and height ast two parameters. . ong maxDelay) : Here, maxDelay is je the delay. It is a maximum weconds that can elapse before boolean flag s Font f; public void init() Output | | Public void initc) het | setFont(new Font("Dialog*, Font.80LD,18)); n(“Style="+d public void paint( Graphics 9) isBoldl ) 9.drawString(s,50,50): else 4g. drawString(‘string isnot bol 4.drawstring( $50.80) S.drawString(msg1 57 ‘escrbe ay aura The Graphies class ; starting locations space is decided by the Graphics class is. points, corner jets cuits ‘ yresenting end ‘applet > tag. A Java applet draws Tresenting end Phe Example: gfRect (0,10 * drawRoundReet ( ) and met are used to dav hods are ods ‘Sdrawline (20, 20, 60, 60); » ated ind he ie areeots tO mh ot nial ): // Elipse een) 100, 100); // Girele /* ig/APPLET>*/ Program 5.20 :To draw loge of Olympic (5 | ‘74 Drawing Ares re S.drawString( "Groovy!*, 50, 150 ); | p /* {* Graphics g ) { 10, 170, 80, 10}; { 20, 40, 140, 20}; xPoints.length ; 9-drawPolygon ( xPoints, yPoints, nPoints) ; pnd fillPolygon () sig A ali or filed potgon can be drawn toi fPolygon ( ) method which again requires arguments as drawPolygon ( . s.drawPolygon(xl.y 9fillPolygon(x2y22 , *sappver CODE = Poly.class exGHt = 250 OTH « 200" YAPPLET=/ 1g methods drawPolygon ( ) in object rather than having ial arrays. This approach involves Def values as an array. Defining y coordinates values as an array. Defining the number of points n Creating a polygon object and initializing i with above x,y and n values. into The variation of y, a8 sraphically using following progra™ Program 5:28 :Appet to draw tine sr2°h __Program 6:28: Appletto raw ane 96 _ 7.7 Drawing Bar Charts farChart extends Applet cena circle cla oe he as [/apples/ wi ees tad with conc ot ted 1 Write an appt which shows come Sy yllow color respective ray eure to accep Pare ‘i 4.1)

You might also like