You are on page 1of 16

Chaplen 66

Appltsand Graphicg
Applet An gplel is mall ogplicadion d
embecdesd Oith an HTM gile hich is Proctsgd
Over he indernet

Applek Byte Coce + HTML

Di4ounce bthoeen

Applicslien P m Apple P0970n

Applicatkons hove mdin Applel dos hot kove


mthod main methed

Anplicatien i ecuted *Agpleds


indegendert HMfile

Cum b embeded
Applicaieng Connt be *Agplet
enbedod h HAML, ith H M

Connot u Libsai
AYplicatien prostuns Con*Appledg Connol
U he bsni drem sm otho CsuPngu
ang
ava iya leb Oo{ 4o 86ppor

ui n ppets
Aite ycle
An ple Contain ditenu ztaq
) Born gol
8) Kunning
delle tade
Dead tade

Aplet is
Bovn init)
LDaded
bat

pait)
onning
ede gtde
topt) dudroyt
(Dtad tdt
Borntate.
hen
Whun an
pplet i loaded en eecotien
i in bosn

Runvi n
hen un he ecutien
in SUnninng

Whtn n pplet iá Oaitirg meime


etuti en hen in Jdle e
DMadte Compltdi en e eculien
movy t o dead ade
stade
Applel Caag
Methods
wed to move
tartt) => Thi
me-thod
anapplik
Ho TunninA toe
&top C)> hiy mthod iy d to mo m oppklI
4o idle
inid C => lhig method i ud +o initialize he
he
Variableg , 0bjects Colorg ee .

poiC)=> iy he hont a n apple PmgTm,


he aind c
ht method i ugedto diplay NaTeug

idtglace elemud CHe brHeons, Lsb textfields


Checkboy,ima,
pobli Vor pod(Gyxaphic )

3
epai ) = » Thi method

Pplel induy.

public veid vepaitCGyoaphits )

3
This method, i uged to tdsuue
bpddeC) =>

oriculan porin Cpplel indeug.


Ex public voi pdede CGvaphits 9)
dyoy
AAteye Corrpleien a n enttARen
applethun d n
9p/et dedsy method e d to
move OMM
appletto a

Simpe Applel P'sOsam


impovt Java. applet «
impOrt Na.aot-
public class E esterd Appled

Poblit void paid (Gpaphics )

dr GingAeltome to
Applel", loo oo)
3
Er.htm

Body
appled Cade E . clay
hoidth = L400

htigke .A

lapplel>
lBod
E.clasy
avo C E.ay
opletviaven Ex.himl
LoppeL> 4a

applet Code closs.name


Codebse closs .hore URL
Oidth pixels ,

ktig Pixek
AHenode -ie
hagace pizd
VspCe pi el
</applel>
Method o4 Gaphic cla

dzaoine Thi unctien d to dreus a Line


Oh n applel

Stax 9.dauline i t it y,id 2 i t y)


Er .dosline Clbo,too 4004oo)

Ex
impovt va .opplek. x*
îm port
public elag ettunds Apple

public oid pair (Graghic, q)


cyouokine Cioo too 400 +00)
Gmphic class
class
Method
a
to dra aline em
> hi^ funeti en ig ued
earokine C)
an gplet
, it y int 12, int
}2,
Syrtax > 9-thouline Cint
(Do, loo 40o, koo)
Ex 9 - daakkine

Exjava
Ex. hi
import Jva.applet .
import Jva.akt. 6ulpvl
publi clasy E exterds Applel

Publit voaid pairk(Graphics 9)

drooine (i0o, loo, 4do,400)

3
3
a dvrouoec L)»hi hundii uge to dsa a
Rectangle
n an p l e

Syta draus Rert Cint , int y,int 3, int y)


Ex 9.drtusRect{I0o loo,t00400)
3 )dvaoRou nd RerlC)>This fundim i ued to dsu oound
seetangle n on
ple
Syntaaq dhavsRound Reck Cint , int y , ind 2 it , i t ang

imt anglea)-
N
Ex 9-dvavsRound (Recl(loo loo, too, tto, 35 35);
)draoovalC) >"Ihis tuncie i ugdo Condruel
(onr) Cicle an plet
Xc,int ye, im
zidth jnt ysidh, .

Syras.doausbval( int
E2 .dras0val[l4oo 400 20o
200)

5 dra Are C) >Thig funclien i d to dra


an

c , id ye,
it
langle, int 19ngle2
Syntas >9-dhaArc (id
int 2aralet,it 20angte 2).

Ex9.drawArc(4do 200, 45 0 130 o )

funcdion ed to dsaus a
i
sdraoPolygenC)> Thig
Polugen n Pplet
, i t y, int length)
Syotax>9-dsasblysgn i t
5,280f;
Exint xLJ :{1o0,150, 200, 350,
350,20o3
{loo,18o, 30o, 450,
it
Hl3
.dsaoPolygen (i, y, 1 . length
kab (oqsam 08

roram to demongtrate Graphit cag


8write

wncien ike int, Reckangle, RoundReckangu,


Cirde Elipe
Arc, Poly n ugin

import ova. pple.* E.JavO

import a Ya act.* *

public cloy E
extarda Apples

Publit void poid (Graphits

int too,I50, &0o, 350, 25,%o


3
int yth1oo, 180 300,450,360,30o

-droavsine (350,50, 50, 5o),


150)
9-dvasRecd (450, Ioo,550,
9-draoownd Rect (450 300,500,350, 35,35)
-drobal (Hbo u00, Ibo, t00
9-drasDval L50o,4oo, 200,50)
drodo Are50,500,45 90,
150 10)

-doas Polugen ( ,y, z.lenqth)

3
<html E. htm
<bodu
Code Ex.clasg
<applet
Oidth 4 0 0

heiqht4do >

slapplet
/body
</hml
Lab Psoq ram
to
whrite d java applet rigome
impert java.applel*
import a.at .*
public clasy £ e extends Applel

Public Void paird CGrophics


9-dvaoStirg C"Name =umku", loo loo)
athon Name ABC,loo,12)
9-dvquSbing C"
Mothe Name =XY2", loo 40)
-chtoString C"

-daSing C"Cowue BCA" loo 160)


-

9-dsatviog C" Semgten= 5th",


loo,18o)
ronaStrirq C'Colle qanne XXX, TUmKbT",100 200)

3
<html
<body oictth00
opplel CodeFx.clem heiqht Ro0

/opple
bdy
/htm
Aab
to ccept nd diplau
Write On apple Proram
udent
dekaile.

impovt JaYa. a p l e . * *

jva.QAGt **
im pb
.t
impbst Java.aot .tvent
Ex etends, APPaimplerneri Attien Liytehu
public cauy

i r nd
Sti name
i Ceuue

Si m
T Pield 4 49t3,t

Laloel 12,13,j4
Buten b
Publi Void init)

nexo Label("Edan Ragno")


e o Ttpidd C5)
L2 neo sbel C r t , Name,
1 nto Tetfidd(IS)
l3#ntro Label C"erdo Cunue
+3neo tfieldt15)

h ehen
LabelC£rttn Sem")
tureo TextPield CI5)
bne Butten gubmit")
add(
adl)
sdd (L);
adcta)
addfl) Java a
TDec
add (Lu) e e c u t e

Tnese
bddAcisnLietanethis) DBc

publit v6d aclienorfosre CAckionEverd e)


. Hegist
ClasfosNae
4edsosncel)= =b)
a. Cresle th
vegno"egno" + t .qUTett
Conneetien
ame "Name"+t2.qdTertC)

Cuue- "Csunue:"+ 43 .getTett )


3 Cvese
Sem "Semien"+44.Tx
Statenmerd
repairdC)

kEecte
public void paid Groyhiuy PtayHet

5.Ch
rwao tvi gh, l00, 200)
Con. Clag
sueStim nume lo6 220).
9-sausaing (aug ,l00 2uo)
9-aSring Um,100 260)

tml
<body
<applel Code er.clay htiqd-00 Adth=q00>>
s/appl
<[oely
Java Aa Bage Connettivi CTDe
TDec iy a ova APT to Conne and
execoe the oith he datubage

(hese teps to Connect ith he dedabap


ging DBc .

.Kegigte the drivnclosy


clas4orNomeC" oradle - jdbe.dvivon. oracle. drivon")

a. Cresde the Conneciem object


Connestien Ccon -
DiMans.geConnetienCjbe :edbceb
dcod, "sco""tiqe)
3.Cvete the gtademen obje
Stadered gt Con. Crostlattment)
kEsece
ReuH&elg g .eLuedurry leet 4 tron tmp")

5.Coge the Connection objec


Con. clayty
PPlets
Advantagu otb
Appleta r e gported byrgt
Applets ve Sun any lAor m.
Agplets e
he Verin
DaAdvaniages oPplets
desiqn nd bilt d
St is d4cut
indexyaae.Copeot
Aechnoloqies
0thu echnolo9i

Sueti on ,

Im
)What Pplel 9
-

alhot a ne b Plicatien P0m sund


pre sam?, 3
-

3plain Lie yele


he n
e -5m

4)Eplai n init, epaird, poir)


5) eplain polet +aq Im |3m
s)Eplain mtthods hics lauy

) plain edodsbaue Conniviy


)ohe the edUaoriaces diodstaqy
gplet 3m
numesi

Jawa. gpld
.

impor
m p o r t

vinport v a .anot

clam Ex ecterds Appled


public

publi c void Gaphícs )


it

S i n -value 0f Ca)
Stri S4r

-dreglring (gbs, loo Io00)'


3
3
npa ug uginq dialoque Box.
Getti ng
*
impost j Gva. applel
at*
impovt Jaa
*
impor SNaX .
i n
public c lssg Er ettndg Appled

Sering S $2,ans
public void initC)

"Edey 48 ne")-
S bpBien Pane. 3hsusdnpultDi otdgt
("erln 2 o.").
$2 Joptien Pane .Sheuo npud Dialog

it b d-deqe. sTnt (S)


in u m Q t b

"+t»ing.Valueen
too qumbe
Sum SauM);
a

void pai (Gaphics


Public
(ary,
100 o0
dranSUsinq
LAB PROGRAM
apple PTogrtm o undotan d
an

ov
inmpert java.applet.*
mpost sva.aot.* *

impor java0t.evtrrt.*

Publit doass Ex etendg Appled implemedts Ackitni

Pot4
String s
Butem b', b2, b3
void initC)
Public

bineO BurtttPlain ")


b2 he Bute ('Bold")
b3 ne Butbbn3talit")
addb)
add Cba)
addCb3)
bl.add kti onligtaneo thi)
b2 .e ArtionLiattnu (this)
b3. addAionietn hi)

3
Public void ackion tajowmecl(Action EvertC ))

Ce-gebSounce C) =bl) =

ners FoAvial", Eont, PLAGN ,20)


SAy lelcomt do Appled"
8Afod():
upai t
3
Hge
Saunce C)= = b2)

A nevofor C"Avial", Cord 8oLD, 20);


t "Wtltome to Applet"

SeFord Ct)

3
H(eedSbunce L)» b )
neofortAsie" Ford TTALSC 20)
Sty H«lcome Aco Apple"

Sel Fond

3
3
Public void paind C6raphit 9)

9-dra Gtsing Btr,l00 l00)

You might also like