AJP 22517 Lab Manual All Practical
AJP 22517 Lab Manual All Practical
r□ I 9
File Edit Search View Encoding language Sel1mgs Tools Macro Run Plugtns Window 7
�e 0 � 1o1 I I o. c. I 0.. a. I [;) B I � q ·=- <I> Clrl Cl Ix "' � I @ I»
E3 CheckboxGroupOemo Java Cl
1 import java.awt.*;
2 class CheckboxGroupDemo
3 {
4 CheckboxGroupDemo()
5 { 1§.1 CheckboxGroup □ X
6 Frame f=new Frame("Chec-kboxGroup");
7 CheckboxGroup cbg =new CheckboxGroup();
8 Checkbox cl=new Checkbox("C++",cbg,false);
9 cl.setBounds(lOJ,_ - );
10 f.add(cl);
11
12 Checkbox c2=new Checkbox("Java",cbg,true);
13 c2.setBounds(_ , l , 1 , );
14 f.add(c2);
15 f.setSize(1 .., 0);
16 f.setLayout(null);
17 f.setVisible(true);
18
19 public static void main(String s[])
20 {
21 new CheckboxGroupDemo();
22
23
24
II
ava source tile length : 503 lines : 24 Ln: 13 Col: 11 Pbs: 303 Windows (CR LF) UTF-8 INS
'°
file Edlt Search View Encoding language Settings Tools Macro Run Plugins Window ?
o'J ei -" 1r. 0 ®J e I : l.o I "? � I °' a. I ©. E\. I § Ii}] I =:=; 91 ·=- <!> Clll � .fx � fo3 I @ t:1>
�ponentsExample.java (31
1 import java.awt.*;
2 import java.applet.*;
3 public class ComponentsExample extends Applet
4 {
5 public void init()
6 {
7
8 Label l=new Label("NAME"); ,. Applet Viewer. ComponentsExample.c... □ X
9 TextField tf=new TextField("Enter your college name"); Applet
12
13 add(l);
14 add(tf);
15 add(ta);
16 add(b)
17 }
18
Applet started
( \I-.,, ,._\s,,,r Kt 11 [r J\ \D•�1 /1\e' t... AH Pr �r ,rn,;,, 1ppl, t\ Jt' 1, r I w1p n• r t-...f ;,r: i!IJ Ii f 1ml
II P
ava source file length: 349 lines: 18 ln : 17 Col : 6 Pas: 347 Windows (CR Lf) UTF-8 INS
·=
� C:\Users\s.anke\OneDnve\Documents\AJP Programs\Selectlanguage.ja..,,a Notepad+-+-
F1le Edit Search View Encoding language Settings Tools Macro Run Plugms Window ?
ol e, .,.. - @ I:)) e I db ID rn I 9 -" I 0. C. I ©. 0.. I [;) 1!3 I 3 cu </> Ctil l!!!l fx � ::a:; I @
� Selectlanguage.java Ci
1 import
2 import
Applet Viewer Setectlanguage.class □ X
3 public class
Apple!
4 {
select language r Marathi r Hindf r English r Sansknl
( l)<.,," <., dlki:'1(r1eflr1 ..... \[) (1.11,:rt< /1lf rr )t,fc!!l'-').--l\cH '-.elt->tllcHflJcigr-' ]:1'd
■
Java source file
t
I. Practical Significance: . fr .
The List and hoice components lets the user choose one option om hst of availab!
options A hoice is displayed in a compact form that requires you to pull it doWn
see the li t of available choices. Only one item may be selec�e� from a _Choice. A Li;
may be displayed in such a way that several List items are v1s1ble. A List supports the
lection of one or mor List items.
Constructors:
List() II allows only on iL m to b I t ·d
List (int numRows) // no of ·ntri • will al , i ibl
List (int nuniRows, Bo lc,in rnultipl I r ·I
ct
multiple items. If it i fal th n only n item ma
6
Maharashtra state B9ard_ofTechnipal ducation
·············
---------
�dv�ru�1ce�d�Ja�va:_!P�ro�gr�am�m�in�g�(22�5�172_) ------ �
············································· ··················································
............
.............. ,,
..... ...... ...... ............... ...........
...... ........ ........................................................................ ............................... ...............
··································································································· ········· · ········
.. .... .... . ······ ······••1
........................................................................................................................................................................... ...... .. , ·
.. .... .. .
...................... ................................ ........................................................................................ .............. .. ...... ........ ·
··· ········•·,
Ready made Practical output Available Checkout Now ♦ ••• •• • • ••••••• � • t. ♦ •••••••
t ♦ •• ♦ t • • t •••••••• ••• ♦ •••••••
♦ •••• • •• • ••••• • • ••••
••• ••
♦ .........
..... . . ♦ ♦ . .. . ...... . . . . ♦ •••• ••• ,
XIII. E rci e:
I. De elop an applet/ a�plication using List components to a dd names o f 10 d1· fferel1J
cities. · ·
2. De elop applet / application to select multiple names .of news papers
(Space for answer)
•
J-":......'�0..f��t.....J.9-.Y:.�.:..9-.P..I.:..'�...)...............................................................................
'\ \c ' \ •
.
\ •
t ••
.....0.�.�..?.-:9.-.9..��.�..�.�.r.��..�'J.J........�.\..Mcl.C�..s.2�.Y.\.f..�.�.�.:l. -L ....................... .. .
....:-3..'.:..°:�.d t '' - ��-�'-'�_?:t.�.'.:.L;,..... ,�-�--'..?.:�.� ..C'...9J.f.:.i_g0,_a.,_b.,Cld. '.'.J )•...... .... ·
✓
\?
J l.".. � a. (\.J e.J .'' Ji ..... ..1.,.:.o..d.d.( �°'_\-�a.a,�,,. J;......... .... ...
....J. _o..J.. ..... t, .. (I
:
---�-�-��- .... �-'--)•..�. . . ......... .........:.•• : : : : : : : : : : : : : : : : : : : :::::::::::::::::::::::: : :::-::: :·::: : :: ::: ::::::. . :
.. · ..
Ready made Practical output Available Checkout Now
1 import java.awt.*;
2 import java.applet.*; Applet Viewer. MulttpleNewspaperNames.class □ X
Applet
3 public class MultipleNewspaperNames extends Applet
4 {
5 public void init()
6 {
7 List ll=new List(�,true); Toe Indian Express
Hindustan Times
8 11 . setBounds U , � u,l , 1 , l - ); The Hindu
9 11.add("Times of India"); Maharashtra Times
10 11.add("The Indian Express");
11 11.add("Hindustan Times");
12 11.add("The Hindu");
13 11.add("Punjab Kesari");
14 11.add("Maharashtra Times");
15 add(ll);
16 setLayout(null);
17 }
18 public void paint(Graphics g)
19 -{ Applet started.
20 repaint();
21 }
22 }
r'llt , ft ,,11H�,,\J<; rVtr qnr
\l J I'll, l'- ... , 1, pi 1' 1 11
1(1 (l I l(l4--; 1 18]
:d I q)i! c.. r ,....'-t, \t\
I 11<.tr'-\'-alKt {J.!D ,\t' [li l1 m,rt'- ,11r P•,�r-JrJl',)]<:1 d( 'h]t1:l,',,,c..�dlt'rtl llr'- ]r1 c:
1 llc..,r'- -.,,11 K' ! r fl n, D tt11nert'- ;;, P P ,lfr illl'- cir J,t\ 1,,,,r 'ult q 1, 1i,• 1 p p,, 'lorn•<.. t tnil
II
Java source file length: 423 lines: 22 lJ1: 8 Col: 26 Pas: 174 Windows (CR lF) Ulf-8 INS
( pa for an er)
Q
cy. \.......-
....- ..... :. .................................................................................................................................
....-
�.....B.9..�J.�r:r\-�19..�J.. (.).... � .s ... :r.h.L..g\�J.� ....\.t ...\Q1-0.½-. :\... fqy .... 1:.r.9: ....e.
. .0.Dcl . S\9.w..l9:.�.o.Y.-:.\.JJ ....\. .S ..• \h.€.....c\.�f �Y.-..\.i... \�:j.o.v..J .....t.Q.� ...............
. .
. �f.?.�..�±.. f. .. ��D..�J... : .................................. ·······............................................................
...... .:
. ....................................................................................................................................................................... ............ .............. ............... ...... ..........
!...........................................................................................................................
..
�-'2-:). ........................ . .
......................... ................................................... ,, . ,..... �............ .................................. "·················· .. ····· ........ ....... ................ ............... .. .. . ..
•••••••• .. ••••• • ••• ..• ..................."!'....... .................. , ....................... •It♦ ........ 0 ....... . ..... , •• ••I ..
....... .. •·• •••••♦♦\♦•••:..
:
.... . .
. .......... .. ........................ ............. .. ........... .... , :····-······ .... · .... ................................. ............. .. ........ , ....... ..... .. ... .............
.. ..
.
.. ..
. . .. · .
. . .. : ..
..
. . . . .. . .
Maharashtra state Board of Technical I ducatioo
15
...
..
. .
. .
.. ......
Ready made Practical output Available Checkout Now
Advanced Java Programming (22517)
I. Practical Significance:
The CardLa out cla s manages the components in such a manner that only one
compon nt i vi ible at a time. It treat each component as a card hence known as
CardLayout.
..... . ...
Ready made Practical output Available Checkout Now
.d an d Jovo Pr grnmming (2�2�51�71)____________________
..............................................................,
···········.....................................................................................................
.. ........
................................................... :.......................,.............................................
.............. .. ,,
..
........................................................................................................................................... ............................................ ..
,
MenuBar mb;
MenuJtem ml,m2,m3,m4;
Menu mn;
MenuShortcut ms ;
MenuDemo I.()
sctTitle("McnuBar I mo");
setSizc(500,500);
sctJ ,ayoul(null);
ms- new McnuSh�wlcut(' l • Ev
nt.V );
mn· new M ·nu("Filc");
mb-.ncw Mcnul3ar();
: ml� new Menullcm(''Ncw ... ");
m2-ne� Mcnult m("Op 11...");
m3-ncw Menuftem("Savc As
m4=ncw MenuJtem("Exit",m ... );
");
. Maharashtra state Board of Techni
.._. cal Education
············· .
Ready made Practical output Available Checkout Now
.
Jo.."' �. C\ wt . f_'V � • ¥ '
• I
. ' .
�------+__c_��-�� (
L------·, .s L1·1...� l G. () o J .6�('.)_t>�)�· _______· _, _· ___.,;.___._· ---�
:....--------' £�- S�ViJ' �'o tt_ :{�uz.) J
�----n-
t�'; <, -Vo'\cl, HP ,-,3\a.� '-'o.i\J cJ l
\b .. SIL\, (:'x t ( \ �ou O('(Q_ � -n \
-}
Ready made Practical output Available Checkout Now
Cl
·=
•C\Users\sanlf.e\OneOr1ve\Documents\AJP Programs\JTreeE.xamp!eJava - Notepad ......
File Edit Search View Encoding language Settings Tools Macro Run Plugms Window ?
� ei 131 li;\1I @ IE)) e 1 :::, 11. I 9 .,, I o. C. I ©. e.. I § 1!3 I :::; cu <!> CtIJ l!!!l tx � ::a:; I @
f=l JTreeExample.java f.3
l import javax.swing.*;
2 import javax.swing.tree.*;
3 import java.awt.*;
4
5 public class JTreeExample
6 {
7 public static void main(String[) args)
8
9 JFrame JFrameMain = new JFrame();
10 JFrameMain.setVisible(true);
11 JFrameMain.setSize(4 ,4 , );
12
13 DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("India"); □ X
14 India
15 DefaultMutableTreeNode maharashtraNode = new DefaultMutableTreeNode("Maharashtra"); [jMaharashtra
If [)1i1umt>a1
DPune
16 DefaultMutableTreeNode gujrathNode = new DefaultMutableTreeNode("Gujrath");
DNashlk
17 rootNode.add(maharashtraNode);
18 rootNode.add(gujrathNode); DNaopur
19 [')GuJrath
20 DefaultMutableTreeNode mumbaiSubNode = new DefaultMutableTreeNode("Mumbai");
21 DefaultMutableTreeNode puneSubNode = new DefaultMutableTreeNode("Pune");
22 DefaultMutableTreeNode nashikSubNode new DefaultMutableTreeNode("Nashik");
23 DefaultMutableTreeNode nagpurSubNode = new DefaultMutableTreeNode("Nagpur");
24
25 maharashtraNode.add(mumbaiSubNode);
26 maharashtraNode.add(puneSubNode);
27 maharashtraNode.add(nashikSubNode);
28 maharashtraNode.add(nagpurSubNode); /11 ,,c, ft \111J 1,c; V 1 1 r ]l1 U l l•44 1 vJJ
29 \ l r 1 , o..,{ ♦t r, i i ,• 11 r• /d I q�t t.., , , "t' \1 i
30 JTree tree = new JTree(rootNode);
31 JFrameMain.add(tree); ( ll'>t'I--, <.,d!l,<,t\lrtD J 1 [) (IJl1lt'r1<., hlP r'•(t' n.., 11\,i lTr,,Fx,•rnp]l 11\,�
II
Java source file length : 1.258 lines : 34 Ln:14 Col:10 Pos:373 Windows (CR lF) Ulf-8 INS
Cl
·= </> Ctil l!!!l fx � ::a:; I @
� C:\Users\s.anke\OneDnve\Documents\AJP Programs\MouseDraggeoanoMoved.Java Notepad• ....
File Edit Search View Encoding language Settings Tools Macro Run Plugms Window
ol e, .,.. - @ I:)) e 1 :::,i rn I • -" I 0. Q. j ©. El.. I [;) 1!3 I 3 cu
18 MouseOraggedandMoved.java ElI
1 import java.awt.*;
2 import java.awt.event.*;
3 -public class MouseDraggedandMoved extends Frame implements MouseMotionListener{
4 MouseDraggedandMoved(){
5 addMouseMotionListener(this)
6
7 setSize(300,100);
8 setLayout(null); □
00 X
9 setVisible(true);
10
11 public void mouseDragged(MouseEvent e)
12 Graphics g=getGraphics();
13 g.setColor(Color.BLUE);
14 g.fillOval(e.getX() ,e.getY() ,20,20)
15
16 public void mouseMoved(MouseEvent e) {}
17
18 public static void main(String[] args)
19 new MouseDraggedandMoved();
20 ii C:\Wmdows\Sys1em32\cmd.exe -java MouseDraggedandMoved □
21 hi .., 1t , 111":lruc.. IV\! q r lll fl Iclfl1� l ,/]
1�) llllr p-..u�t I pr it .._1 t, ,\ll 1;.;htc, rt''-cr ej
( \ll-..,-,r-, '>dl" (!e!J 1 t-' [J1 •mt'rt-..\\l� �r•lf,rrlfll'>>]1 c1• 'l!,',t'[)rd6f:;t'ddr,r, t', ]d cl
l \l t"r 1-.. c1t>(t-' (rerJrl�t-' [)Hurnt'rt-.. AlP Pr(�rrlrn >],• d h_,11-,�[Jr,, ,,t'e,•r 11,1 el
■
Java source file
·······················································································································································
: :: :: :t: : : : �: ��; f�: ::S.:t;:;; :�: :::;;::�i: ;9-X;:IS. i::;:;:�i.: :cs.:: :iii.J.>: ::
.... . .... ..... ········································· ········································J· ....... .... ··························
............ :J.t.�.�.�.�.. .£�...n.<!:.'-?....'1.f�9':�.� ..C�.Y0.$.f�.��.......s.\.�.�.cA....�0.0.f.J.u/
: : : ::: }�9;..;�:�J.i�:��J.:::::;;;::��:i:::i:::;:;:0.: ::i:��:;j:��;di:,:·:�:�d.:?>.:J:
·······················································································································································
···········7.\���.\ .....0..� ...� ..�.�� ...�t0.�.�J..(.��.J?<3.ff..�.Q.Y.Q.�-::.J... J.........................
............ �.\.: .. 5..�\:Qo..�:a.d.J. ...l�.�.1....�.�:9..1.8..'?..1... �.9..).. !, ..........................................
...............v..Q.\�.e..:..}.�\.3.9..lf..D.d.I. ... .l\<?...?..J...\.9.�.2.\�..?..!..?.�.)../ ............................
· · · · · · · · r�·�d· ·c·v;·�·�e:J··· ·;:··. . . . . . . . . . . . . . . .. . . . . . . . .. . . . . . . . . . . . . .. .:· ·:
.................F�..a.d d. (._,l.\.. J.). ·..................................................................... ·.........................
. . . . . . . . r� . .s.�\ . ..s.,·.�g... .t.?.?.�..l.�..�.�..1...;...........................................................;.-...· �..:.. :.-: _· ·.
················· � ·.···$.:<??.t\.�'J.Q��\-.. (.D.0..�.. �J;................................................ ::::.:: ....-.. :.: ... :......
r_
. . .
................£.:.5.:Y.v..t'.I.�.b.\.� ...l.\:1.�.�. ). 1.' ................................................ :... :..:.:.:..:...........
..................................................................................................:......................................................................................................................................................................................... -.
..
.......... ...... ..................................... . .... .... . . ................... .............. ......................... ....... .............................................. .
.. . ................. .... ...................................... .... , .... ............ ♦ ......................... . ..
.. ,.............. ............. .... ..................,. ................... ...... .. ...................... . ......................... .
.... .
•·••••· •··••··· ·•· • ••••· •••• ·•• •• .. •• • •• ••• ••·•••• ·• .. ••••••I••••••••·•"•• •••••••"•·•••••••••••••••··""• .. •••••• ••·• •• •
•• •• • · • • • • • •··•····· ••·•·•· ·
. . .
·•: ............... .. ............. ............ ........... ....... ........... .. . .... ..J ..... " ..... ........................ .... ............ . ......... ........... ...... : ...... ..... ....... ........................................ ......... .
•-. .......................................................................................................................................................................................................................................
. �a� rashtra �tate Board of Technical Education
� 67
. . . ...... ....... .
...
..
. . . ... . . .. . ...
.. ... ..
ing (22S l ?)
Advanced Java Programm
uir d (Ad<litional)
VIII. Resources rcq
Nil
l)
IX. R ourc s u cd (Additiona
importja a.io.*;
importja a.net.*·
public class lnetDemo
try
{
InetAddress ip=InetAddress.getByName("localhost");
System.out.pr!ntln(::Host Name: "+ip.getHostNameQ);
S)'stem.out.prmtln( IP Address: "+ip.getHostAddressQ)-
catcn(Exception e){Systern.out.println(e);}
J
J
Ready made Practical output Available Checkout Now
XI. . t Jt (Ou p Jt of 'od ):
•• ¥.T
". ·• "•••••• .. A ... •·1•• I .,.,..,.' )
J ..<,!...................... :....... ,.,. .. ,.................. , ... ,..,, ... •••••••••••
�����:::::.·::::;:::::::::::::::::::::::::::::::::::::::::::::::::: :::::: ::::::: ::::::: : ::: :: : : : :: : :: :::...·•···· .......... ::�. :�: ::�::::
XII. J•ractical I< ·lah·d <Ju tion
Note: Below givn, " "j,•w ,11mplt• lJIW\l/om /or rt• ·rn . , I •11cl1a
. ",.
n rore wch qtte.\fimr\ W> tM to l'll\llf·,, 1111' 11d1 i' •v,,,,,,,,, I I0/ 1de1
mu, ·r tie ·igll
. 1ti'i
.., t•ti ( .v.
.,..
. I . W r�tc
· o11y I <,ur c 1 ·Ill ·n:n ·t,• I, ·1wl l II IPV I urnl II' b.
2. Wr'.t • U�c ll'-,<.: c,I tclByN:.11J1t:() .and gl't IIH. Nam. _l 111 . lhod.
3. W11t�tl1t'>lq>•,tc,a'>,;igull'·•idd il: ..,· l ll Otll Ill u: 11111 •
·
.. ... :.· . . .. .
Ready made Practical output Available Checkout Now
Java source file length : 648 lines : 27 Ln, 14 Col: 2 Pos: 344 Windows CCR If) l/TF-8 INS
Practical No. 18: Write a program to insert and retrieve data from
database u ing JDBC.
J. Prartical ignifi an e:
ODB i ?'t appr priat for dir ct use from th Java programming language because it
u a mt rfa . Th JDB Pl wa modeled after OD but b cause JDB i a
Ja Pl, it ffi r natural Java int rfac for working with QL. JOB i needed to
provid a "pur Ja a" olution for application developm nt.
.. :. .. . . .·
Maharashtra state Board of Technical ducation 9
. .. . . .. . ..
· ervJet i HTTP dependent
rvl t.IlttpSe J t _ H
1 set of rul s that allo Web browsers and servers to
n r and support the H TP �rotocol Java-
atio n dent on ervlets. HttpServlet is Extended by
t
ll p b tract cla s for the developers for extend to crea e
p C ts.
Nil
R ourc u ed {Additional)
I. Write a Program to send the usemame to server and server will send the length of
username to client.· ·
2. rite the output of :following code cosidering below HTML is front eni::l and
servlet as back end
loginp�ge.html
<html>
<body>
<form action="
http://localhost:8080/examples/s rvlets/ er I t/Ath nti nti n n I f'
melhod ="P T '.>
· c;cr Namc:<inpllt typ -"te t'' nam ="u rnam ,i br
Pa%w rd: .,... input type "pu � w rd" n·lm ="pns ,, r i"
.,.,input typ -- 11 subn1il",
.,.../fo,n1..,..
/buoy,;
/
"' html,,
Ready made Practical
• I
.... . ...
·. •:· .