Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
48 views
80 pages
Java Project
Uploaded by
Ayush Shrestha
AI-enhanced title
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
Download now
Download
Save java project For Later
Download
Save
Save java project For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
48 views
80 pages
Java Project
Uploaded by
Ayush Shrestha
AI-enhanced title
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
Download now
Download
Save java project For Later
Carousel Previous
Carousel Next
Download
Save
Save java project For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 80
Search
Fullscreen
Creating a swing frame and making wt clasdble \nport javex. swing. x; public class Myframe Trvame F4, My Frame ©) F4- new Trrome ©}; 41 .setSize (300, 200); AL. sek Visible Crue); Fi. set Default Clase Operation TFrame. EXPT ON -CLUSE), ah. static void man (Sting UI args) , Myframe ML- Rd My framed 5 Es 3Creating a closable Araene USIAg inherhance venport Javox SHAQ. ; public clase Myfrane extends Thame Vglramec J § sdSizg (800, 200) ; Se Ress zable (false) , SVs idle Grae); SH VeFav Clove Operation (TFrome-EXETow_ clase) 4 Public shat vo'd main (Ging Cj arg ) Y WyWrame mi - ngs My Frame C); 5 5LL —————E_-— her (ait;$; Oo rresvvr—- Create a ftom ame with Sve buttons using F louiboy ouf: import — Jovar. swig timpor gavo-awt 5 puble class Using F low doyout , Tiome f4, TBurtion 61,42, 63, b4, bS, Using Flowbagout She new Thame ©); £1. se}Si20 (1200,1200), TL SATite ("tay Frame), Fr.seedeFautt Close perahion Chamero -CLose), Ay, Sef Layout ( Now FlowLayout (FrowLa 1 Burrtons %L = new Iurlon( "One 4 b2 = new Tatton ("two") OFF Read TBukton (thveg “ PAS Sead Teuton (oS ya” {05 = Mew Button (five); & . Youre LEFT, 1g, (0)); #1.addl b1). $y.ad4 (v2), Sr. add (03), Fr.ad) (b4), Sy. add (bs) 5 FiSerVisihe hrue)s 5 public stale void Main (Shing C1 argo) 63 UsingFosbayot ul = Nea Flos Leyact OGEEE lll Create a Rame using Border Layout import Javax Swing 5 port — java -aut. x ; Public clage Using Corder Layout v Thame £1, . Teton bi 62, 3, 64,55; Using Qorder Layour () fie New Tame Cy £\ seb Size (1000, 1000), FL. sak Title (“Border Bae"), 4). eee Oprebin Tame. Cxr_ow. Lose); Fr seYLayauk (New Border! avout y, bt cnew TButtor (“One”); b2 = MW Jeotbyn Ctwo"), 23 = ME TOtton (Taree), ae) TButtor (our), Se mes SBstton Nive “Sy Fi odd bt, Border Layo uc Sovrn), £y. odd (62, BorderLaqout- Nagy), fy. Gadd (v3, Border Layout. EAcr§, F1. add Co4, Cover Layout Westy, Fr. add Cbs, BorderLayout-CEnreR y, Fy .sekesible Grae); pee skate void main (String CJ args) Using BflorderLayout Ul e mere, Using Borderlagout(); "3 "4 4‘reate the flloong Ayame wing FlowLayod and Border Layout \nperk jovax Swing 7% import java-auit | 3) porl’e class layout F | [end Too] Tove fFeur) Terame fL; oman Noyouk OF Fiz new Thame); ; #1 -set Size (400, 300) , 4) -cerBefaurtCloce Opevertion (shame. ExTron- close); fh se LayoutC nen BorderLayout() ); TGuttor b1,b2, 43, b4, bS 5 bt = new TButten (dne"); b2 = Me Teather ("two"); 3 = new Téutton (three); 4 = New sButtoo (" Four") 5 * Ae Teuton ("Five"); TPanel pL = new Spandc); pr-add (b1)5 ®. add (ba), add (2) + 9) add o4) Brad (Pt GorderLeyout SOUTH) 5 on add (BE , Border Layout (ENTER); fy set vesitlelb-ue ); 3 publve State vord man (Spiagl) args) \ayout [ = Nes layourt) 5Create frame with buttons using Arid layout Import javar-swing .x, import java.cwk -% 5 Public class UsiighwidlLay out oS 5 3 Thame fi; c Tut 64 523,44, bS; Using Grid ayout O Fl = New Tame Os #1 -SekSize (500, 500); F4 SebTitle C'drid Layout"); fy + Set DefautrClose Operabion (Shrame EXT T_ on_ CLOSE), F1- setLayout (new Gridlayout(3, 2, 10,195 bt = new Terr toa ("One"); b2 = New TBurbn ("Two"); P= Nee F@ut-ton ("\Thyee "); bd = new Tether Pur"); BS > nent Button (" five"); Fi -odd (b14);, 4)
e-gvidy = 1; abe “gridheight = 2; O>c-gridwiat 2; phe Bi = brid Gag Congharts BoTH; GL Seb Conshegink (64, ghe), Fl.add(b4), bt sme Tutto “Seven” } OC -gridx = 0, Dbe-gvidy 23; Obe-griduid Ne xs Obc-A'll = rid Bag Condhrain ls. YORI ZouTAL; Gl set Contra inks (57. ghe); fi.cdd( >), Fy Sehyiclble (tue), pole stab'e vard marin (Shing CJ args) Using Grra Bag loyou} Gol = new Veg Grid Bag layout ) ; 5 5No Layout - Create 9 frame with Latels(Neme, Age, Javax. Swing - 3 Contact), Text Felde and import — javax. 67% Bublons witout ong layout Publre clase NoLayout € — ‘Thame £1; Trobe 12, Eo ee Tutt BL, 82; Westfield TA, 12,73; NoLayout () * Fycnes IFrame); fi. setLeyout (null); 44. sexTitle ( “WoLayout”); Fi set Default Close operarhron (Thame, Exit ow-cvose), 44. set Size C 40°, 400)- LA = new TrabelC" Name"); L22 nes TLabel (" Age") LS= new TLabet (* Address” )s a = Mew Jtextfeld (), V2 = New TTextReldd )5 TH+ MW TTextField(); Oy 2 ned JT Button a 02 = me Teuthn (* Cncet") LA set Bounds 10,10, 60,25); Fi add (L4); TL. setBoundel too, (9, 160, 95); F1.add (191). L2-S4 Bounds ( 10) 45,80,2S); Fi. add (12),T2 -setGound s (100,45, &, 25); F4.ad (72), LB Set Gounds(10, 80, 50,25); F 4 .add (12); TS. Lt Bounds (100, 80, 160, 25); t4.adel (73); G1. set Bounds (100, N9, 8, 25); 62.set Bounds 199, 110, 80,25); Fy .add (81); £4. adel (Bo); F 4. sotvisible (true) 3 Padlc tawic vord main (Sving C4 arg.) Notayout ob= New NoLayout(); 3ee ty, OWING a : E'S Oe Create. a Qvut with vent That When the button ts clicked. 'mport jJova-awl-*, displags “Hello Keto | aeraal “Import Jova-awt- event -% ‘mpork JaVax- swing 2, Public class GUT With Cvent_ 4 ‘onpements Achion Litton § JFrame ft, Teutton 1, Test Fe ld roy DUT Wihevent_ 1.0) Fines Tame); fLsetTitlel "Gvent Kandiing-f)% Ay. SetDefaclt Chore Uporation( Tame. ExiT_ ow -crose , Fi.set Size C400 , 420), Ay. a2 Layout (news FlowLayout\)) Shenew Verte dis), Bh enew Testton ("ok") bi. addAchion Lickene-C thrs); F3 add(te); FLadd( bs), ft-setWsble Arve), Public stahe void main (Hvingl3 args) ned GUT WithGent 19; 5 public yoid achonGrfrrmed (Ach‘on Event e) 8 {1 Set Text C" Vetlo" ), 3Create a swing PUL wl @ Text tield and tue buttons (OK and Or) When % button © clicked “Hello” shuld be displayed 1 te Ab Freld ron clear butbn «chewed, Fextfield should be cleared. ‘port java. awt-*5 import java. Guit- event, MPO Sava. Swing. 25 public class SwingGUECvent 2 mplémval PetonLahew § TRrame aft, a Téutton b1,b2; SVertfield 41; Swing AUT Event _2() $ Fle new Tram); Fisek THe C'GuingGur Event. 2°), | OO FA set Dofauh | £ | seh Size (400 400), i. Seb Layout ( new FlowLayout () ); MF PeW ST Hecthie Ja (is); bt: new T6stton ("Qe "ty Pe Ae BAEC Bau"), bt adel Achon Listener (tie); b2. adel Achon Listener Cthis)5 F1 -add(ot), Fad (ba); $y .cobvesibl Chee); J public shate void mary (Shing) args) new SwingG UT Event 2(); public vord achonPerformed (Achontvent e ) Pog (e- getSouree()==b1) +Lset ("Hello"), “set text"),i " a The buts ate g suing HVT uth 3 DF Pons (red, lolug: Green) «When ‘pons we licked They veapechive backgrand color should be changed. K-<> ean e impor} Javon Swing xy iMport java.qut: ¥+ Red \ |e “Mort Sava.quit: event, 'mpor JOVOX: Swing: 3, Public cag, Red GrreenBlveB implements AchooListene, § IFrame Fy, JGutton bib2, 42, Red trreen Glue AG, () Fee Tame; . Ay serTittel “eedGranlve BG"), FL. SetDefatt Close Opercabon ( TFane » EFIf_on - CLose ), £i-Set Size (400, 400), 44. Setlayout (news Flow Layout); bi snew Teutton (“Res”); 22 ned Téutton ("Green"); b3 ene TBurten C'Blue")+, caddAchion Listene (Anis); C2 ald Aon lanes ne), b3- ada Achva Lishena (tres); StaddCbt); fiadd bo); Fvaddlb9k $y cctvici : Puble stahie void mag, (String) argc) 5 New Reddreen Blue BGy 0; Le Cree), Public void achonPerformel (Action vet 2) ¥ iF Ce.gehsSource) <2 b1) * ol set Background ((oloy-ved), else iF ( egetSource ()-. 1,2) ¥2.set background Color. green); Ase 3 8: set Beex ground ( Golor-blue), 5oe a swing VE wih 3 buthag thon te butthone gre ched they res pech've bheame lor Should be changed, imgort java-awk: *5 import java.awsk-ewent: ‘onport javax SWING; public class Frame Color implant Action Listone p° Trrame ft; {-2> frame Color Teucthoo bt, b2, 3; el Ba (Red | \ Gye Bie Fame Color ) i 5 Al: nur Stramgl); Ab SATAN Feione Clor'’), - FLssek Default Clove Operohn (Tira me. EX1T_owv. C LOs€ ); fi set Si2e (400, 400); 44..get layout (new FlowLayect ()); bie nas Teutton(“ Red"); be: Naw Tootton ("Green"), 8 mew Tarn" Blue"); fr.addl bs), Ai. add (62); 44, add (b2), b4- add Aekion Listener ( this) « vp. MiaMen Uslere- Onis), be ada atin starr (is); £,_cottsiWeUvee) ; Public ratio void man (ering lI avs) § pee Frame-tolor 0; public vord qetorPochormed (Ackonevert @.) ; « (egotSource) 22bL) : Ai get Content PaneW)jsek Back gvound (Color-ved); Selse of Ce.getSourcec) = =b2) § FL get Content Pane )- set BackgroundColor green), ase 3 Fr-get Contertt Pane “ Sek Background (Color -blue ); 3dt OE ware a swing MUL Tha tee} f 1 sppercase ) When lowercase cand veo een loess Me Clik, rent of toxbfield shold chanted inte \cwer-case aril —— | . inngor’ java aut y ionport jae. quot “event: 5 tonport JAVOK Swing. 5 Poblic class Lower and per ‘on donnants Achertistene $ Wrame fi, Teuthn bt, 2, TTentFed t1; lower andy O eer andy Flenew Thame): Fh. sor Title ("Lowe and ape £1. setDefautt ose Operation (TWeme Exit _oru - cv); F 1. sek Size (400,400); Fi -sehLoqout (new Flouleyout()); bt nes Tathy (Lower Case"), 2 Mes Tutt |" Uppercase "); tt nes Tretfeld (is); bi -add Actonlistene- (Huis); bo add Petion Listener Chis), Mtoddlts), fyodd(bs), Sradd bz); FL. sot Visitle Crue), public shale void rain (hingl] avg) F new Lowy and Upper C); public woid achen Perhorned (AdctonEvent e) © iF (e.getSoure = =b4) : ib CegeSovretinn Sying S2Af. goblet; AL. ser Text (5: boLowerCase 0); else § Ning sith. get Tot Os £4. sebTexk (s. to Upperlase | )); 342 \ 3ene ee ee aele abe) cod a Bie aa hn ig hued , value oF teed Se fu chould be checked and Y Ympork — Javay. Swing x-3 Shatd 45 play oddiGven in label. WPI java.cut se, Iimpavt Java awt- erent: >, puolic — ctoce GUT in plemerts Ac Lon Listenee € Thame 15 : TrertRu t4, Tlabel LL; Turton bey Gott Pye tes Thame; fh.cekSize (200, 309); Ly. cet Defra 4 Chose Operarhon (Frome «Ex (Ton CLOSE); Fy. sok Layour (ret Flow Layout ()); Aye new Trot Fietd (io), bE = nw Button ("OK"); Li nq T@Laber (); Fi. odd Uy); f4. add (LA); £5, abdl bs); by. adel Action ihe Cnr): Fy. corvisible Crue); S publ stale vad menin (ering CI argh) $ new GTO; Sable word aehon Ser foveal (Achonbvert er ink ae Totegerporseliat (41. set Tet); ¥ (ay2220) I+ gertext (“even”), e\Se +5 Li .setText ("odd");rreme A Fain OVE wth tet, lebet and bitty. dhe, button IC cliched, Cd value of Heet-fehg ‘thal be chected tnd Odd) Even . shou F vonpayt Java Swing ; old be displayed in @ message bow, ‘port java sawit:x-, import java avot erent «5 public clos Gut fonplements Achonlisters & Thame FL; Tout thn bi, Fret fed ta, atop diene Thame); 4}. set Size C 400,400} FL. Set Default Close operation (Thrame. Ex\T_on -CLosé) F 1. setLoyout (new FlolayorO } 41 > news TFlertfield C 10); bt > nao Teuthn(" Ox"): Ft.add (th), $1 addlbt); 64, aad Acton Lickres (this); ftser visible (hue )y 5 poblic Stabe vard mat (9) arge) F new GUE (); 7 public vold actinforPemed (Achin Grend e) f. tht a Vhegey. parse Txt (+1. get Tew) # lang 220) Toph an Pare. chouMes sage Dials (nut, Bey ") Ave 45 TO pon fare. show HessaseDi'alos (rvtl,” Ontel "Meare a GUT with Derk fe U (Num 1 Num? Result) 4 butters (Add, Sobbvect, Mulkiply . Diyrde ) “then buttons ove lice - impor jayax.suiee Calculations should be do “MPork jaya. Quk A, port java. gut. event x, Poblve class GUT inplementy Achon Listener § Trane fy Tfentfield t1, 49, 42; TLabet l4, L2, L3; Betton bt, h2 b3b4; Govt § fyznews Thame ), A). sek Size (400,200), FL cet Default Close0pera hon (Frame. EXIT. ow crore), Fy .set Lagos (new Govrdlayar( 5.2); Yas nes TertFietd (). +2 = new TherhField O); 43% nwo TextField Oj, bie neo TBurtn( Add’), : 2 = Ney FButton ("Sbbact"): 3 sna TButton ("Multply"); b4 = new Toston (Divide). Lie me TLavel ("Numi"); L2 = nw Tab (" Num2"); L382 ner FLabel Recut"); Fiadd (Ls), F4.add (+4), Fi. cdd(L0); Fi.cad (42), fh. ddl), 24 aald (+2); Friadd lot), Ly odd (b2); FtadaCbe): Fiadd tba ) ot Ato, Listing, (tha), Pa. edd Achgn Likeness (hie); 53> add Achon Uclens ‘hh sf Tbe gai | che re3 Public shabe vad ’ New GUT (), mam (Wing lI args) peblic void achenferbraned (Ahsatvert e) at 2 nF rete PorseL t+ (44.5¢4 Terk 0) ), tak Ser. parseL 4 (ta. St Texp-¢ J, ‘Biles "Get Sovree () = shy) Cs ats. eee s iG Ae af (0:46 Gyre, O69) ©> ase b, f Ce-ge ouree ()= 24 ) eat) bo); Gi Ne Cz a/Z, Si tset Teed (c4" Di 5 aSCreare 9 swing Guy wilh @ Gambo bx and Sent fol). Whar em in combo bor ix seleckd, '4 should be displayed wh tomb fel. Nobe: Bohn AehinGient anh Tem@iest are geneakd her Hem In & Combo bx is Selected. yy Mood Jove. awt- event. x 5 impor) jOva-Gut-% ; snpwr Javan 6rd g ks puoic clacs Combobox “Trome fy, WertFeld fs; JtomaBx ch; . . Lying ciel Je S$" Kahmanda", Bhaktpair » Lalitper 4; CemboRo x( ) ™ plements Nehvonlishene c Fle new TRrame : he new Text Feld ; Cb= Nas Ftombo Bor (cihe} $3. set Si 200 400, 409), $1. cet Default Close Opercth en (Same, ExIT_onv CLO ), d. SchLayour ( new Flowlayout())- cb» add Actin Lishene (this) Fiadd (+4), 4 add cb). 4 i-set Visible (ve); 5 peble shite ved mata PyringC} oan) F nes Combobox ( ), 8 public vard Bho Perk, ane (Achin Event e) og LU SATEN (cb det lecdel Them () 4 " ), 3— EEN NI ES _ Create o Frame — with fue ee} folds and horde Feeus fyent on WOS¢ tent fhe fds Smpot Jovax coring. x; Mort fvaawt Mort jovc- awl: erent ¥, ble clase Prius Events tanplenreals Foraslistener f ie r Tram ft, Vreerfiely 41.42; Focus Evert () © ns nes THrame(); Th. gas TText field (5), 42. nee Text Rel (15), L- set Size (200,200); §- Set Layout (nee Flockagout ()), fy. Se Defeult Close Ogererhvn CTFrame ExT on clHe ); FLadd Cr4 ); 43add (42). AL add focwlichons Chic), +2. add Focus Lichenor (hs); Sy34 Visible Che } Public State vord mary (ying Org.) 3 se focus Event (5. pee void ‘eustrained (Rout ont e) \F (eget Soe )- - 41) tt Set cates round Clon scenery, ese S 3 42. Sek Bow grDund ( Calor. G REEN ; g——————— Create a GUL which changes fle. beekgrorcnd co\ov b Frame acuording 4p BHouce Suent- import jova- aut x, import javor: Suing x, lonport java. auit-event-#, public clese Mouse -Ewent in plearants, Horse Listener § TRrame FL; T Label a Mouse. Gent U) £1 = nes Thrame 0) $4. set S:2e( 490, 400); FL. sekDefault Close Operattion (SFrame. xtr ON -CLos€). F¢-sehLayout (news FlowLayoutl )); L4= new TLabel (stab *) Kad CL); A) add Mouse (ishener( thi), 5 fy. sek Visible Crue), Public static yerd main (Shing C4 orgs) Mts, Mouse Gren thy Publ ic Wid mouse Entered (Mou seEvent e) i fL ger ContentPane (eset Background (Cofor MAGENTA); public void MOuceE Xitel (HouseBveat e) , 41 gettontent Panel) ‘set Background Color -ORECWY, 3 public void mousePraced (MouceEvert ¢) 8g, get Content Pane () sot Background (Colo RED), gCEES" publre Void Mouse Relecied (MouteEvert ©) Fe 1.get ConbertPane(. set Qyexeqround Ccolor. BLUE); F public word mouse Clicked (MouseEvent e) Fe, get ContentPane ( )- sek Bacleground C@ior. Yeiou ); Ssee Weake a Got Mh label (lame Contact) ane “Bul elds One tered muck only Rove Weer ee Gh pact daly take numbers. import Saver Sing impor Java: aust xy tor jowa.qush everk=*; public lace Khey - Event extends Meghdapter TWrame { Thabel Lit; MWextfelg £1, +2; Key Cienb() g Ft 2 New Thrame (); F1 set Size (Soo, Soo), £4 .6e\ Defans tO poration (TFrame. EX TON CLO); Ay. set Layout (nee Floslayoutl)), Li.new Tlabe} C'Name: 4. La, me Thole (" ticontaet") Th = now Vextfie lb(3),; 42. now Tlextfielg(\5), tt.add Keslichenoy Chis); 42-addkeyListene, (hve), F100 (14); F1.addl £4); Fy od A(L2); St add (42); Ay. setVisible Gre), g . public Statte vord main (Shing) args) Mer Key Event() ;ude: vate MesiypeA(Kerevert ) chav c= eget Key chev Oy '§ Ce.gekSouree (5 = 43): ‘ i$ CiCcpe'ah ZR ees’ \y Cay Bhvec- zy ¥ e-consumel; 3 5 Ase i # Ces 08 cez'9)) : €- consumed), Wyok, Clear) Creare & GUT wilh texfeld and tuo budbns a When ‘OK! iS clicked, ello should be displayed 0 . Sela and hon Clear is clicked, extfidd shold be gL eonyty: import Javarswing: Ay, impor Java. aut Cuent. ¥6 y import java. owt, Public clos ‘wnerclass Thrame Fy TBubton bt ba, Trextfeld ty, innerclass( ) fhe now Jframe(); 44, sek Si20 (200, 200)s Fi. sek DefauthC\s se0 pera on (Thame. Ex TOn_Close) SL. SetLaqoutnen FlodeyoutC)), bis new TButtnC on"), b2: new Teurtea Clea”), AL new TTextfield(1o), Fladd ltt); Fiadd( 4), Fi odd(b2), BL add AchonListene rea HandleCvert Vv), b2. abl Acton ickoner (meus Kaudlle Coen ()), 41. exckd setVisible Chee), ee publi ckahe void vain (Shing) ange) new imMerclassc), Class Hardlel vent lp lemonts frebion Listened Poble vom ac hion?orforned (Acven€vent e de Fe-getSeuree() #2 bt) He seb Rt Cello"), We te cebtext(™ "\. BPPCroce A Menu base ap oA meny bvthes (FILE, EDIT NEw! And MenuTtems Céxit Frame J import JAVA - Sesing-*., import java-aat. vent + 5 public clase Menu App implenants Action Listenps $ TFrame F145 TenBbar mbar; Tren File, Edit, NEw; TMenuTyen mid, mids Menu Based Ae) t fhemew Thromel); Fiser SizeC4o, 400 ); 44. coy Default C\ose0 perabion CTFrameEx tt on -C LOSe)s moor = new TMenuar 0); FILE = New TMena(" File"); EDIT = me TMena ( “€dit"); NEw = new TMenu Cika "). mil = new Teneo ("Exit "), mi2 2 new TMenu Tem ("Frame ry fadt fle % ed'tin menubar mbar.add (FILE); mbar. add( E017 ) ; add Nes and exit int fet FIle. add (Wew ), FIle - add (mit), Nadd frame ty New NEW - add Convr2), add — menabar in frame At. set TMeny Bar(mbar) ; $e mengcere nid. add ActionListener (this); nid add Action Listeney Chis); fy setvisibleCue}, 3 public ate void main (hing args) 6 new Mean Based Ape ( ); pale vid achoPer firme) (Actin rested) “F (e-getSouree ¢) Baty oslo ase P Z New OUF withévent Osa SCC a . ra & GUT uth @ listbox and tert fold. When stem a istho 5 SThax yg Selected they mate AS plaged hb fede fia itypor + JOV x: Sewing x "port Javaxswing-Oventaie, port Saver awit: x: ' urbe Class [thee wit forte ld implement lish Selechon Listener 8 Trame fg i, Tlext iets tL, Tur ls, listbox wis tertGel yg Mena TRame(); ALe new Tfextfield (10); AL. dSizg (400, 400); Ah ser Defeat (Close Operation (Tame. Ek \T_ON-CLOSE} Ai-sctLagout (new Flow Layout); FL addlts); . | A Shing Avinks (J> $ "Dew", “Come”, “Feats”, Sperbe Deeper” “rage’, “Mineral Yaten *, “Pepsi 3 Li znew TLict (drinks), Li.ada Liskselection Listanee ( tus); TS cool lPane sip = MO TCoroll Pane (LL); fad (jp); LA. setGelechinptede ( Lit SelechionMede | -HULTIPLG DnrrequaL Lect $5, cetvirible rue), aw) 3 public state vord main (String J args) £ pee Ustboxvittadfald 0; 3 Public void value Changed List Selec rent a)f Shing hams 2 Uf. get Selected Value List) e's Hc Tat (Hens ), out tye ae); Wabe (“at oes & idpined (fel ese #ONbS Selected ee thie) ‘ a Congas hnCrete o GUT with 2 “rege butltiy Wher The Teqgle Sut 1h 6 pressed On, display “Button i On" Whn bitten i released, display Button ec OFF in 4 Message desley import Java Suing x; impor Java autre; Import java. qut- event Achion Giants import Java. aut: event. Achiolichenen, Public class higgle butt snglements Actioilietener £ TroggleButhon 4; Traore Ns, : fo99\e button l) AeRew TFrame(); F1..setSize (400, 200); Fh sebdefault Close Operation (TFrame-EXITowCLose 3) 4. sehlayoul (new Feulautd); bt = new TTegg Button (“owloge"), by, adel AchionLictener (this); 3 Ftallle 1), Fist Visible (true, public stahic vid main (Sing J arqs) : new tryglebuttont; public yoid achon Rorformedd LAchon Event ef # (bt. 1 Glected Oertre) Toptin Pane. show Message Dialog (out, “thon is Orv"); aA " eel Tipton. ane. show Message Pialog (oul, ation 8 esCreate a Soing GUT shat uses Trable with cloms b AVi were Addrese an) Cal ary The respective ana Shoo 4 S¢ disp Veeck - import Javatut -x, import javay . Soa Purotic clase 7 TTableDemo ‘ TFram e 4, Vrable +4, TScrahiPane SPs Tae Dene () Nnew Thramec). F1.s¢ Si2e (Soo, S00), Fy. SeDefau Close tpeabon(THane. EX\T_ON- (ose) FS set la york (news Floslayeut()); Swing Gls 2 $5D" "Name" nNOS “SHAY? Obfecr deta {] (0. 86101, ‘Rom’ og aku, ", N99003 | an Ke’ "Serkhu” {OOOO 4, fies Reman’, ' cube Smee} manand “ . y By pet | ) Foo 7 - tiene Tablef deta, cols.) ; P= me Tarot Pane (4) , ft. ciaCse), g Tied Jelwe); ven Stabe voi main (String ty ans) . now ThableDemo4) 5 zithe, display The Ueate the given ovl. When Submit brn by clicked , disp lig Provided ‘nfo rm ation in a oe a o ‘port Java. Gut %, ‘npr fave. tat even AchiogLichener; ‘part java. aut. Cent ActionGront; in por £ Jav OF-Suring, eS publie clog ¢ Avm Vrplemenk Achwrlistane: § Wame 415 14 Li,L2, L4.L4; T RadioQ.tton Lys The @ox cl, C2, 8, ‘TCombagac ch, Th eek fred 41,42; TOntton ba, Aovin ) + -new IFrame, My. SS. 2e (Sro, S00), Losey Debout Close Operhin Creme FxT_ON - CLOSE J. £1. SHLagot (neny Layout Uh uy =e TLabel (Name ") 1963 Terie (16), Fiadd lL 1), Tied (+1), 2 =new Tabe] ( "Faculh,’), 98 CoursesC) = "Bien" “gag” ‘Bn, “0a -F¥, b ores Jorn Bo Cour ses, Fad (L2); le add ( cb); LB 2 ned Tbe] ait “ Ne'''y YLe new TRadio Rut bon (hal ay 22 nes TRadioQathm (" Ryale"’):uttenGrovp £9 snow Button aroupl); bg-addlrt), bg-add (v2); 44 odd (12); Fs-add (41). F1.ada( r2):, V4 me TLabel ("Hobbies"), TACO CL = ney Thee Bex” Yagic"), 02 nay 0 Baa gat Treivetag'). #1. add (14), ax FL aad (<2), 44. add cS), DL Fhe TButhn (“Submits bt.cad Action blxkene, Cre); ft.add (o1\, 3 4) set Visible (Ce); public stah'c void mai, (ring) as) New form (); Prbhe vord action Peto real (Redon Sven e) Shing Name = the get Text Q - Shing Faculty cb-get Selected Them) + j Sring ferder aN # (v1 elected ()) £ girder "Male"; dase if (+2.teCelected (3) ; gender = "Remale”s Gring hobbres .""; 4 Ces, teSelected ()) © hobbies 2" Muse, *F Ced.teGelected (3) hobbies +>" Reading" if Ce& ie Selected ()) hobs es +2" Wu, Abia 4 [ TWprionPane shows Marcas Dialog (Aull, “Name. Name + : \nFaculhy:” faculty + "\a Genders "+ derden 4 "\n Volo ies. * + Yobhies oFvaign Meare 6 \cibbed Pang, with heading Shident and 0 da Th Student. here mut be Name and Aacully ws we Guavelian Mure must be Name avd Celt No with Wey feet Bras and — tombobok -whe- fn Faculty. import javar awt- x, Mport javax Swing: , Public class TTabbed lane Deney® Fame ie Tabbed Pane. tp; TPove 2,92; Teer Fiety HW, 42,42, Teombo Lox ch, TTabbed Pane Demo C) Tho new Trane (): Ay. seb Ging (Soo, 500), FI. serDefauttClp Operation Teme. Beit Ony._ CLose); fy. SetLave ut C new Floslaut()), PL = nw JPanel); C1 = Me TLahe| Name “), 44+ neu TTert Field ("%20), 2, Med TLabet ( "Racal by"), - Sing FacathyC)-$" Gap" "Bim", Ber-e", BBS’ S, Ch: nes JCombo Box (Foc uth); fenes tePsehLayout Coan Gyidlayout (2.2.9,5,); P1-a§ (11), PL adel Wo. Pt: ada CL 2), Pl.add Cob); P2 = Panel (5, 13 nay Fabel (Name), a eg STex+Fepy (20), 4 = ney Thabel (Ge No!) 00 Feet Fels C20), p2- SeHayout( new Gridlagou- (2,2.5,5)) f2. sdd¢ (2), P? add (49), P2- add C4), P2 aad 43); tp snes TTabbelPane()s tp-add Tab “Student”, pds . tpaddTah ("Guardien’s p2); F4 add Up )s Fi cet visible Crue), publi’ stahe void main (string CJ args) re = Tabbed Pane Demo ()-, S 3Write a Program 40 show Colo-Chooser and change ie background of Frame a8 per The aaiiae import java, koa, Import javax. Suin 5 imports java. ant Action Event; smport fava. Gwt-AchionLi'shenay 3 Public clase Using (olorChooser implemen Action tere 5 TRame Fy > TButhn bs, Using Color Chooser ( ) fF 1-¥ new TFrame (); AL. SeHTitle ("Color Chooser”), At. setDefay\tClose Opera bool TRameE xi on ud FL set Size( 400,400); FA Set Lasoo (neu Floulayout)), bL snes Teuton ("Choose Colov"), by. “AN chon Listener (his), FLadd (b4), ft. set Visib)e (free), 3 publ stale vod main (Shing C3 args) F new UsingColo-Chouser() 3 Public void achonPerfrmed (AetionE vert a) TColor Choo ser- show Dialog Cat, “Choese Color, \ * (olor ¢ Color-yellou), FA. got lontent Pane) “SehBodleground (c) 5-_ eet i. * Cyeake ow GUE ork menhar ath heading File - Dpside vt, Menu Them (Open and Save) shows be iden deter Thaw Should also se TextArea in Pe gol Whon Open ve CWeked, spent file can be opaned ead i ‘ortorts Should be degleyed in tertfles «Silay, shen We enter Some vacters in Textarea and save ity ved. Cc fle should be Saved. import java. lox, iinport IUAX. Swing. import ® Java: uk a MRE Java. aeb. eran ye public class UsinsTlect Area inp lements AchinLishener 6 Thame 4, 3 SMenuBay mbar; TMenu fe; Weauthem Open, Save, Viext Area ts, Using TlextAvea Gy Me new Teme); A. set See (400,400); Ai. cetetre Clore parabron (SFame, Ex iT ot Lose) ; 41. se} Layout (new BorderLayout()): mbar = new TMenuBorC), files New THenu ("File"); OPA = New TMemibtam ("Open"); Save = 1, TMonu Ten Save’), Fiie-add ( open), fileadd (Seve), mbar. add(file) ;il SL SS fi setMenuBar nba), yh- ee STertArea ¢ J TurliPane \> = new Tera Pane Gt); $5048 Sp) ; opervadddcronLishere (4) cave. abdAchon Lister, (4p, 8); As cetWisible Gre); public state void onan (Ging C7 arg) a Using Tact Fate public void actionPo-formed (Achonbvant c) € if (e- 3eSgource Che g pen) TRI2Chagse ioe new TRieChoose-(); ife- show SSE Dialog £4), Shing Medan jhe-qet Celected Fle). toString ()5 String Sz try Fle Tapa Strenen Fin = new Filelnpet Secon Ct file Name ), int chy ohile (C che Sn. read O12 -) S+= (char) ch, fin. close ()y M1. setTert (s), ¢ Seatch (€xcephan et System. out. an (ex), 3— else Mle Selsoreege : an =? Save) Mle Choe, > es Tle Croeser (,), HC-shon Savy, ( . oy 4 g 41), ea eName HC apt Sede Fl). toShing "84 Content th pero, ary MeOutptSream fut ayy Fle Ott resem lene Aout. wrtle Cos stent. gehPytes()), o Catch (Cxceghon «) S3hem. ob. print lal ex) Four. close () 4—_—_— ee - Create Your Coss Own eg box venga ee vnport java. quot. ay innport J9V4 Quy. ‘pov F impor Petion Crank, Java, awk. erent. Feb “onListenes Javax, Swing 3x, ng J PeledBoy plement: Action Liskenen urton bs, Daley a4; TLabel lt 112, 3, a ) Th New ie Pevimon bLengs TButhoa(’ About Us"), bi, 8A cionLishenee (hy, 's); Fy. add Cb), , SCE I'si ble a Ure), oan Stabe Voi 4 man (Shy Nes ing} argc) $ Using Dialog’); Pe word achonPer firmed (Action Gxt e) AL = new IDale “g{4), AL. gebSize (200, itete Dew Campus”) U2: New Thales la keh man), ara. ‘ l-S6er44 ‘) dL. add (uy, oad d Clay, dL. adh (Lay, AL.set Visible rng), 5aching an ALT Frane and making it closable Import Java. awk =x, import java. aut- event Ry public clas My AWT Fame ecbonds Whdowtdepter § Frame 4, Mg AwT Frame ( m9 SY: Ne Frame ( ); MS -SetSize po, 400), 4. add Windoslistener ( i) Ay. eet Visi ble Crue); 3 Public Stabe void main (String CI args ) 3 Nao My Frame Os Public void window Closing (Windows Event e)§ F4. dispose ¢);- lodttons Veale or AUT me: GUT wath en fiela ve a (ok E Clear) adhen Ox buthn ve heed , "Mello" « | drsPayed in Text Sela. When clear button is chiched, reat ld Should log cleaved import fava-aut - ver} x; © class AWigor a» orbendy Widow Ada pher Parplesenh Ahenlisheng, s | import java.aut-x, AWIGUT 4 ¢ MX tenes Frame ( ); Frecek Sin, (40, 460 ft Staged Cae, Floulayoutd)). f5.addW\rdowab'stenee ( (8); AL enw Text fet g Gey b1 = nes Buta Cox), b2. Nw Button (Clear), bL. AdetAc hon idene,- (tors); * adel Achon| ichener this): 44. add (4), ft.add(bo), £) add Ga). AL set Visible Cue), Public wp ctabic vord mary (String args) New AWTGUT 240); 4public Vad window lasing (Window Event €) § AS Als pase Os 5 Publ Wid acho Rae (AchinEvent e) F(e getSoune (022 b1) AbsetTent (* Yello"), Axe £4. setTexg (0 ") 4Create Gn Sut Ov wh ¢ drop down list (Chore) and a Fort Bed Whon trom 1 Selected, i+ must be displayed in he 4ocbFielg, import Java.quit-»; import Java. dut-event se, Public clags MeTChoice exhonde Windowhdapta- implements istener § Frame £4, : Chace C4; Textfielg Ad, AWTChoiet 16 Frame 4, F4 cot Qs , Soo), oii aa T1.SetLauo ut C new Flowlayout)). di. New TortReld (10), Gc. Ne Chor ce ¢» C1 add" Xs) ch. OU "Beonaph). CL add Xigfin ‘); Fiadd MZhongle") Fladd (41), fall (ea), CL. dd Them, Listene, Ghi's);, #1. sel Visible Crue); Public state vod mary (String) args) 2 New AWTChoreC),puldhe vod window Closing (Window Event 2) ¥ £4. disposet): dispose), 3 public void ‘tem State Changed Dement ¢) f String ch: ch. getSelectel Sreml) 4° 5 XL. SetText Cech);‘ 4 nn Awl Het vith drop down list and a ect Create bles ain them or move ‘han one then is select ld : a be displayed in Ye ext held. sig impork joa .qut-¥, impor Javae- quik: event - x publie class AWTList extends Window Ade te, inglements Themlisterer § Terr field ts Frame fa, List U4; AWT List ©) p FSLenew Frame (); 44 .set Size (500, S00): A4.SetLayout (ae Flowlayout’)); taddWindowliclener (hee) AL > Men Tortfield (10); Lt new Lrst(5, true); UA add (Rawat); Ladd "Yar"), Lt add “Seka! ), Ladd (” Nivmala") Fhaddl +1); ft vadd( (1), UA. add Tenn Lichener Cys), 5 “SetVicthle Chue) y 7 Public shehe vpid aa (SvingC) args) F new AuTLik(); 3e vord windouClesing (Sher nt e) indo» Event ; F4-disposel ), G publ void itemState Changed (Prem vent” e) f Shiny items 0) 2 LA. getSetectedTtenst), Shag ot 2") Asv Grrng m: items) ' Shy 43 ™; 3 AL, sekText (oy ); 3 3(ete on DUTGUT with bibels (Nemeherter and Mobbier with suitable checbox and redvobuthn im port java awit, venpor' javavawk event Achon€ vert ; igor’ jovaaw E event Achin(ishener 5 igor tava awk event X, publi clas AwTcheck Bor ertends Windowdapte, implements AchonLiteng ¢ frame ft, Lobe 41,2, L3; Tutield AL; Burton 1, b2, Chea fhtox 1 v2, tht, cb2 3, erreur Nienew Ge Frame l), fy SetSt2e (Soo, Soo J; fy add Windon| ickener Hs); Fi. seMayput (ne PlowLayoat () J» ea labe C'Name”), MH enew Text Feld C10); 4 add (@L4), 1 aad(tt), Checkbox Giro, Cas new CheekboGyop (); LD = med Label ("Gender"); YS Me Cheutox ("Male”. «5 Salse) 5 ¥2> nay Cheek box ("FemaleY cq, false975, 04D); SM add (r4)5 Ns add (¥2); ae ned Label ("Hobbies"). dbl= Ie Checkbox ( "Muse "\s ehl= new Checleloo (Travelling ° 5 meet Cheshbor Gay) fy.add (8 ); dy. add Cobs ); fy. add (cb2)5 $1 add (
) New Using Cardtayout 5Write a Program to inset vecord in database - WMport — Fava. Sql #s Public clase Unser Record § public stahic void main (Sing Cl] args ) SHring ur\s “aloe senysql I \oca\hest: 3306 / bimSa"; Shing uname + “rook; String Dud 2" onysa\ "5 ay f Class: Sor Name C"com. mysq\. jtbe Drie); Conne von Cons DriverManager. get Connection (url uname , Pwd) ; String sails aserk into Shu dent (id Mame scalt) Values Oi Ram' : Bin') Chatennent Ss on: createStitemant(), st-execute (Sq\),, Con: closet), Sycten. out. Printla( “ 7 Record Inverted), catan (ea &) Sychenn: out prick \nlex), aWrite @ preqram AD update record in database ~ Impout java-sqli® 5 Public class Update Queny§ Public stove void Main (Shing 9 args) § String urle” {de + mysql! localhost: 3306) bina" String onqme = “Yook”. Stig prod ="oysql * , : ‘ Class: for Name C'com: mysql. \dboc Dyiver , Connection Gnd yivar Manager. getnnechon (ur\, uname , pwd); ring Cale ‘opdete chudeat Set Faculty SUSIT? shore tAs\t. ? Stabemant or + Con. crealeStabemenh(), St execute (sq, Con-cloeO; Syetern ork -pvintla Record Updated"), 3 Catch ( Exception ex) é System .ouk: pinta (ex);Wyte a programm bo display ve@rd in @ tabular Foret Krom duvalocse- \mpork java -sq\-%:, ublic Aas Display Records § ° fre public chkthic vord man (Shing (J argc) ; String url« “ydbe 2 mqsq):ll localhast:2206/ bimSa”, Sing unome = "not", Shing pede "mysql"; c lass. fr Nave (" Com. m4 J. ja be Driver "), Connechion en > DriveM ara ger. of Connachin String S61 = "select ¥ Brom studa,p” Stal ment : Rese Resutt Set Ale (rs-next( J) (arliname, pid), Ss sh. execute Duery(<4|), System out: print rs. get Chrng (Mid 4 "ES i Syetemout print (1s: get String (- Pame") 4" \E" ); G4 Stem. out: print (ws. geting (Fecalty | "V4" ); § Qn. close () 3 catch ( Ex ‘Hon ex) $ System. ou -priat\n (ex), 3 3 3 a 4vile preg ram + put \d fromm user awd dehehe elord matching That td from, Te table Atcume databaue. Anh Agble name: Yours J (mn wt java-Salex, import Java-udi-Scanner j public class DelekeRecord ¥ pe shae Vord mary ltdyng C9 args) Stanner S$ > 0 Seannu system. in); Suctem oud preatlal” Glee he td it ide Senet Tat (); String urle ” abe: mga - [localhost :3506/brin a"; Shing URanes vot; Shag pws * mysql) aon Com. mysql “jdbc Driver) Connechion &F Driver Macager- get Cnnechin (orlunacre, pwd); Sting, gal" oelete from Shalt there ide 73 Prepared Strement at coneprepere Staten (si), AGT (3,14); eb brec t-orcede ()) Gyn ("Reed Delohel 3 eaten ( fxaphion a : Gystemn-out:prilalen) 33Pp’ input id and Faculty of a Studeat Fron user and Ake he fetulhy to he nom Faeubhy atording “to Toe. ven PA- “Amport java-sql-x; Umpsrr Java cut: Scanner ; public aclas User UpdaleRe aord public static void main (Ching C) args) Stunner $= Me Scanner (Cyshenm in) System, out - priatln( "Eder id"); int (d < cnet Int O; Senom ine Inc" Seber cathy) ing Faculty ~ s-nexkl), Shia url.“ fabe: ony sal: (lo caltnost : 3306) brn Sa; He unam —" yout . Sng pude mesql ; % ne For Name co Com enysql- Abe. Driver’); Connection Con: Driver Manager . get Gonna hn hela | Shove ; Peay; | “5 Sq). 4 dale shat set ices | 9) 6 “49. Prepared Stolentat see ven prepare Galore aie as he Sebring (1, Faculty); Ste SYM C2, id), Hercete, eA-cose); Syglers-ouh- print" Scorel updated") 3 cate (teagan &) aie out print (ex); a?Create Swing GUE t fapa va, name and Face \ty of “ a Shader > When bukbr i clicked, Save the inher mah iato a table. meen import Java-awt - %; innpo rt Javax: Cofing ‘import — javarawt: event -; ienpor 6 Java sal. Xs ‘enport Javasq]: avedStabement ; public class Save wh iatable “mplements Action Listener § TFrame 44, Tlabel LL, 42,12; TTetfetd f4,t2 ,tS; TButtn bay Save safe rntable O ‘ £42 new Shrame(); i £4. get Title Save info yntable 3 Fy cet Default Close Cperabion (TPrame x iT-on-cLore); £4. set Size (400, 400); Fy set layout Cres Flow Loxo wt) Lie neo DLabel CTD"); (22 Mew Tlabel (" Name ")y LSe Nav Tlabel ("Freulty'); th = new Text Feld (\0), +22 nus Viextfreld (10); £3. new Text Feld (10); bie nas TBurton ("Save"); bt-addAchon Listener Ups), A —=eg = |fsadd (1), fr.addlts), Fh add (L2), Ft add( £2), F1-add(t3); $1 addc43), Fx.add (bx), Fy. se visible (true) ; public Stabe void maa ( ring] args) § Nao Save info rn bable()5 a pablic void ac hon Performed (Achovent e) te *§etSour@C) = =b1) ob vhs Unteger yairsclit( 1. gettext (J) String nome = 42. get Text ( 3 Sring Farcutly £8. get Text}; Sag wile" jabe: ana IT localhast: 3206/ binSa’' Stings uname = 5 "vest"; Strid purd= "mysql"; am F a Class: forName (com. mysq] -jabe- Driver Connechén Con: DriverManager . get Connechon (url, uname pwd); “insert rity shudet (id, nomeFacuHy) values Sng Sqle (2,9,2)"; PreparedStatement sk Gn. Pre pee (sal); Sh sektat C4, 14); ce Ou printla(ex)5 St gerString (2, name); 535 Sts Skving ( 3 faculh)s St ekecure (), Con. close); System. oF pri ila C Record Inserted"), 3 Cate CErcaphion ex) $ = ——————_~ _ edeCreate an AWT GuT with a lad butte a- When load but on 1s Clicked, dis play database information ta trable. Souve Code- Impark Javox-Swing: ¥; wmport java. owt >; Import Java-awt everd - >; import Javarsal% 5 public class Dreplay Data in Table inploments Acton Listener § Thame 445 TBura bit; Disgagdarain Tae OF F1 = naw Thame); F1. setSze (500,500); £4 set Layouk(new FlowLayout 0); £1 .ce} Default Close Operation ( SRrame.Ex IT on -CLosé ) ; bie new TBurbn(“Load Data"); Ft.add (b1); lt -add AchionLicener (this) F4 -cehVecible (true) 3 public shale void maw (Shrikg (] args) § new “Display Daren Trable(); “publ vord chen Perfornred (Action Evert ©) f SHrig url 2" fdloe: mysql #/] localhost: 3306 [bin Sa’; String UIAME = * root’, Sting pwa- i § , Clacs. rr Name (com. mysq). jdbc. Driver"); Connection N= Driver Manog erg et Gnnection(url, “name, pwd); String sa\=" Seleck % from Shudewt” Starement st = con. create Sto ement(); J eee “FRoadySek «= sh.execute Query (sq\), Gag (1 coles STD” oNAME', "ADDRESS" “FACULTY; OoferC JC} datas New Object (S0IC4]; oe i 0 while (rsnexkQ) € data (ij Col = XS. get Sting Cay; dara Cid (1J= vs: gebShring (" name ")s dara (JL 2}= ws-gerSwng (“address”), dota lit (3J= rs. geher ing ( “faculty “), it+5 coo close(), JTable t4- new JTable (data, cols); TSeroPane jps Me TSerott Pare C44), F1. adAC jo); £4. sek Vistble Chrue); 3 cote hh ( Exeeption ex) , Sy chem ouk erento ex)? S 35 2nee records() that 1 Ap +» execute shored pradue : takes A pavamerers rd, pame, address Faculty Gora Code: import java: sal *; impor Java. ati; public class Taser Record £ ain (String CI args) public shale void Ww pbs nw Scanner (System: in); *), © Scanner System. Ouk- practi (“Enter td, name, Tacu ine ths ab-nextLni (93 Shoring name = ob- next); String ad dvess - vb: next(), Sing Faculty ~ obnexk():, Shing faculty urls “jdbc: ensq\\ # IT \ocalhox F: 3306] bimSa", String uname = ” rook’; String pude" : ‘yf / class: forName(" com: nga - Jdbe Driver . Connection con = Driver Manager get Gnnecton tas pad); Caabse Seahemer se aS Gul Feat inger’ records (2 T 0, “ sheet Tne (11d); 2B")s oh. sek String (2, name); aes (3, address); Sr eetSneg CA, Faculty) con. close; : - . System our: prnta Record Unsorted , 3 cater ( txcephon ex System.our printtalex); 3) aeWAe ~ ‘put id, name, faculhy From user ANd insert ypn-bo Student Aable. Svorce Gde: IMPor * JAVA SC(| 3» public Class TneertRecovd § public shahe vord man (Shingl I args) Scanner ob= new Scanney- (Syskem in) 5 System. out- print !n( "Entew 'd, name face thy 5 Ny 1A = ob-nextTay); Shin Name = 9b Next C)5 Sry Facalty= ob next); Hing url=" pdbc: mysal localhost .3306/ bin Sa"; Shing uname =" ‘| Chri pad ° rect : clagg. for Name (" com: mysql: joe Driver") Connechon Con= DriverManager -getConnechoa(url, uname, Pwd) 5 String Sa) =" Asert into Stedemt (id, rare Faculty ) volues (2,2,2)"; Prepared Statement sk = Con: prepare Statement(sal), ae sekTat (4, idd; st. set Stray (2,rame); oh set String (3, Faculty) 5 sk. executed Jj Gon + Closec )a System -out- prontl («g cord A "), 3 catch (Ereaphion fo ae g System-out- preatly Cex); Pd z-WAP to dis plac Soure Code m port java: Sq\-% 5 Public class DisplayRe cova ss publhe stave vord main (Shingl I args )f String url =" jdbc amysal:/! localhost: 3306 | bimSa"; String uname = “root”, Shing pwd 7M, a yecords Won Shdeat table. class. Br vame (Com emysal fale -Driver "); Connechon — Con- DrivorM anager.get Connechor(orl, uname, pwd); Shivkg sq) = "select x ony shdent"; Statement st = Con. crealeStahement () 3 Reaui}Set tS = sh -execute Query (aq) ); while Cvs. next) ) f System souk: printlrs- get Stving ( a VE >) 5 System out print (rs -getSrring (“name + WY); System. owt: print (rs. get String (Cacathy "yy, Con. close y 3 catch (€vcephion ex) : Syghem ‘out println (ex),Create 7 Serve’ thot disclags “Welcmet Serviet and ure cde fir me ang the servlet +0 «¢ wilh web xml Fre. - Source Gde: rmpart jovax-serviet-hHp. x, 'm port Java. io- x; pable class VelloSerylet erhends WehpServlet ys protected void doer ( Wyler etReapercat request, Uttp Ser ‘ Viet Response veaponse ) Yes pore, Set ContentType (“text/ bbm | ") Print Writer pois response get lletent Pod print (" Chtemnl > LhpWelame fo Seviet Clap
Ds pw: cleed); 3 catch (Exception ex) € ex. prin } Crack Trace); Ss cs 3 ty web-xml Swed -aPp>
servlet -name>d One ¢Z(serulet-name>
AsowlekS _ a ae attend? one d/serviel-name>
Cinput AY pe =" sulomt® MMe = "Sabri IS ? Num-seryler pert Javer-servleh-hit p-%5 impovt java 10 - ie; m port jovax- servlef-annoberon « 3 5 @ wWebserulet ("/-form”) public class NumServlet extends Wt Servlet § perecked ord dothet CuttpleruldRequesh request, VitpSerulet Res - — ee) vesponse SetContbenttype C" text] htm! ); it a = Iivtes er ar seTnt (requesy. et Parameter Coum4" : r 4 4 \ int be Trteger- parselnt (request ger Parameter ( “num2")), mh cs ath, Ary 8 Printlr ter ee = vesponse : gcticter() ; pur printin’ ¢hi> te sum is. “te + “ether” ); pu closec) , 3 cat ch C€x ception ex) ex. printStacdk Trace © 5 s 5 sCredre a Servet Anat cheeks whether Given number (Ss Gish, oadevon - htm | :
I <[body> a < [htm 7 Odd Even Servlet \mport javox: servlet: hrtp x import java-jo. *, vnpor t Savax. servi et: annotation. x; @ WebSserulet (" oddeven™) | public class eee extends MrtpServiet $ rorecked = vord dobet Mttperulet Request requash, HrtpServictRemorse J Yesponse ) | € responce. setContent Ty pe ("text ( hte!) | lot as Taheger. parse Tat ( vequah get Parameter Cnams"))s ty $ Print Writer pw = response. get Wyiter (); Ela}. 222 0)€ ; po -print la(*ht >The number is even ht? ds 3 eve § pur-prtin(“Zhi> the number is odd <{na>*), T pu close dd, 3 catch CEx ception ex) § ex pemtStackTaae0 ; $ 5 S| (veare O Servled Frat Prats the fererse of @ werd provided! Arom YWime Sova Code. Cy a metnod = "get" action. “reverse "> “in pub Type 2 “ghext” Name name" /> eigen Aype= “submit” value: “submit "/> <1 body > Dhrmai> Teverse htm] ' 7 Reverse Ser yleb por INORSOrvlat. WH. 9, ipo Java-jo. «; ° ‘Mpov+ Javax-Serulet. annotation. x; @ WebSerylor( "[vevevce") Public clags Rewerse Serulet ertends WpServiet § Protected ord dotnet (Http SeruletRequest request, MpSenlel — Response vegone ) % Yesponse. sotCortentType (« ferk| html”); 3 N= vequesh get Pavameter ("name"); 4 String Buf fer Sbh> new Ghring Gul, (nd; try § Print Wei Yer pw = "APONSE GeHWriteC), PX prinklin (Sb. revere N; ew Close); ZS catch (Exception ex)$ ex. print Stack Wag Q; 3 3°en Create @ servler ‘nat serts data id, name, address faculty of a shade —prourded Fromm YAML Form nto 0 cole Sovra Code « form: htm! htm! > canter . nage” “ rom actin Save * metroid: “get i sey! Crop type." deck nome = id" Glaccholder tf Size Son 2) Cingut tyce het” name = “name” placeholder. "Nye: Size.” 50'/ : Cinpu type = “het” Name = "caddeess™ placeholde, Adds" Size ="50"/> “inpyt ype > “text” name = Feiculty placehelder -"faeully Size = "So "/> aa type="“Submit’ value = "Save Record " />
AddShudenterulet Ienpor Gavax-Servlet- http. , import java.io. x. import ‘Java servlet. annotetion- eat import Java: Sq\. 5 Cs . ens (sty Sheden Sore extends MrtpServieF € protected wid dotnet (rt pSevsletRequest request Hp Sere let Response response) § response Set ContenFyp, (" text/html"); Shing Ol =" dbo :my sh. I localhas : 3306! bpe "5 String uname = "voot"; Yring Pud= |e mie ii; int tae Integer. parseTnt ( req uesh.g et Pavamety (“id ) Sing name < Vequerr « 924 Para petey (" name"); Steing — addvers= request. get Paranreter ("address ); Sting Facaly 2 request got Parameter (“faculty "); Class. forName (com. mysql: jdloc- Driver" >s Conneckon Gon = DriverMemager. get Connechion a hs Stns sale" asert inty chdewt (id. name, address Aacuy) Values (2,9 2,2)", Prepared Shalement SY = con. prepare Stalement(sql.), Sh. sokT at (4, dds Sr set String (2, name) ; sh- sed String B , address) ; sr. Se String (4, Faculty) ; Sr executel); Calc, (Exception ex) ex. Print ShackTWwace) ;ise fC Gea fee eh import — Java servlet: http: 5 import Jjavax cerviel. annotatt on % 5 neh Servlet ("/ create Cookie “)s Public class Creale Cookie Servlet extends UH Servlet § . protected void dobet CiHipServlet Reauest request, wletReaponse vegnne § response cet ComentType ("sext{ nhl "), Cookie cl = New Cookie (“fn *, "Ram", Cookie c2 = ne Codkie ("\n" “thapa"); cr. selMarAge (24% 60% 60) ; c2- SetMaxAge (24x 60%60); response .add Cookiele1), response - add Cookie Cc2);Keadwn 4 QQ ear impor’ java: io-% import javox. server http: impor 4 javox ser ylet- annctation: x; (® WebSerulet (/readcookie ") public class Read Cooki eServ\e+ extends UtttpSerulet € protected vord doGer( Ht tpSer viet Roques requed MifpSer— viet Response response) ® Cokie 0) ¢ request: ger Cookies) ‘yg Prin Writer pet = response getWrilerl), TFC cle nal) Gor Gat iso 5 (2c-lenghh; i+ 4) ¢ po printin (Cookie rame:” + Ci J-getNamel))., pur prinlinl Cokie value + + ¢ fi. get Valve())s 3 3 3 catch (Ex ception ex) & ex- pr int StackVracel):, 2 < 5Create Session USing SevCT tenport java Servier http x, von por + Sava. i@ -X, tempol F Joven -Servlet- anwotahon: x; (webSerulet (* (Create session” )y perlic class CrealeServietSession exterds Ubtp Servlets pootected vo'd docret (HH pServict Request vequesh, UttpServiee Response ves pang di response. set Contently pel text/html ‘), WrtpSession Session « requesh getGessiva QO; Geasin. setMax TrachiveTrterun) C60); ay & PrintWriter pe creaporse. get Writer); pws- println (seasion.getLdC)); iF (session: teNew) I$ . pr-printia (" Welcome User"); Se pruntin( "Welcone loach”); w- closely 3 cater C Exception ex) € ex. prank Grack Vrace-0) i 5 3Nite ISP (ode te digplay —Iritbhuyan University La Fines Cy. Kpage content Type =" tert/ hrm" prgelnvoding 2 Se <' DOME him\>
< body > a4. for lint i= 441-105 i+ 4) p Out Priatlal "Tri bhuvy UY a ' Ohuva: j it” 5 1” riversity J y>
ee aw Ai Splay No of time User has wished @ website
Lhead> Chtles Websrte
< Theacl > 4*}. tat Ounr 205 pe? Lhoty > Page Count is: Ly. out -printlal ++count)-, =|. > <) body > Lihim\ 7rte TSP code * display current dale and time. <- @page vingork = javquutil: x" contertT5 pe = pent hi page Encoding -"OTF- 8 f.> <\poerype Wem\? LAY 7 L body> Sy. Date date = New Date); ouk-printtnl date »; |-> Zlnim\ >
You might also like
AJP manual solved
PDF
No ratings yet
AJP manual solved
63 pages
Swing, Layout Managers
PDF
No ratings yet
Swing, Layout Managers
11 pages
Oops Co3
PDF
No ratings yet
Oops Co3
14 pages
AJP Practical 1-10
PDF
No ratings yet
AJP Practical 1-10
49 pages
4th unit
PDF
No ratings yet
4th unit
24 pages
AJP practical
PDF
No ratings yet
AJP practical
25 pages
Java Units
PDF
No ratings yet
Java Units
26 pages
3 - JPanel basic tutorial and examples
PDF
No ratings yet
3 - JPanel basic tutorial and examples
1 page
AJPPROGRAM
PDF
No ratings yet
AJPPROGRAM
34 pages
OOP II Chapter Two JUI-Swing Part I
PDF
No ratings yet
OOP II Chapter Two JUI-Swing Part I
69 pages
Java - 1 AWT
PDF
No ratings yet
Java - 1 AWT
31 pages
OOP
PDF
No ratings yet
OOP
20 pages
07-GUI
PDF
No ratings yet
07-GUI
47 pages
PPT06 - Basic GUI
PDF
No ratings yet
PPT06 - Basic GUI
24 pages
AJAVAUnit 4
PDF
No ratings yet
AJAVAUnit 4
43 pages
GUI Event Handling
PDF
No ratings yet
GUI Event Handling
45 pages
Abstract Window Toolkit (AWT) - Library of Java Package - Contains 25 Packages With Hundreds of Classes - Used For GUI - Import Java - Awt.
PDF
No ratings yet
Abstract Window Toolkit (AWT) - Library of Java Package - Contains 25 Packages With Hundreds of Classes - Used For GUI - Import Java - Awt.
52 pages
TCC102 Unit3 Tutorial3
PDF
No ratings yet
TCC102 Unit3 Tutorial3
47 pages
1_GUI Basic
PDF
No ratings yet
1_GUI Basic
35 pages
Components and Event Handling
PDF
No ratings yet
Components and Event Handling
41 pages
Ava AWT Tutorial
PDF
No ratings yet
Ava AWT Tutorial
12 pages
JAVA Unit 4
PDF
No ratings yet
JAVA Unit 4
80 pages
Swings Java
PDF
No ratings yet
Swings Java
90 pages
Course 11 OOP: Graphical User Interfaces in Swing
PDF
No ratings yet
Course 11 OOP: Graphical User Interfaces in Swing
20 pages
Java study Material Unit V April - May 2025
PDF
No ratings yet
Java study Material Unit V April - May 2025
16 pages
Layout Managers
PDF
No ratings yet
Layout Managers
14 pages
JAVA Swing 2nd Edition - Manning
PDF
0% (1)
JAVA Swing 2nd Edition - Manning
903 pages
Swing
PDF
No ratings yet
Swing
27 pages
Java Notes 8
PDF
No ratings yet
Java Notes 8
116 pages
UNIT5-LayoutManagers-Part1
PDF
No ratings yet
UNIT5-LayoutManagers-Part1
9 pages
Basics of GUI in Java
PDF
No ratings yet
Basics of GUI in Java
52 pages
5.1 Java Swing
PDF
100% (2)
5.1 Java Swing
139 pages
Unit-1 Awt
PDF
No ratings yet
Unit-1 Awt
43 pages
Layout Manager
PDF
No ratings yet
Layout Manager
15 pages
Chap4_1.awt
PDF
No ratings yet
Chap4_1.awt
78 pages
Unit - 1
PDF
No ratings yet
Unit - 1
43 pages
CHAPTER 1 and 2
PDF
No ratings yet
CHAPTER 1 and 2
11 pages
Unit 1
PDF
No ratings yet
Unit 1
10 pages
Chapter 1
PDF
No ratings yet
Chapter 1
32 pages
Chapter 1 Swing
PDF
No ratings yet
Chapter 1 Swing
40 pages
AJP Assignment (22203A0041)
PDF
No ratings yet
AJP Assignment (22203A0041)
26 pages
Module 5 - Part 1 Swing Controls
PDF
No ratings yet
Module 5 - Part 1 Swing Controls
24 pages
Unit IV-Part II - Swing
PDF
No ratings yet
Unit IV-Part II - Swing
28 pages
Layout Managers
PDF
No ratings yet
Layout Managers
73 pages
AJP Chapter 1
PDF
No ratings yet
AJP Chapter 1
11 pages
Swing 2. Layout Manager in Java Swing
PDF
No ratings yet
Swing 2. Layout Manager in Java Swing
13 pages
Java Swing - Introduction
PDF
100% (1)
Java Swing - Introduction
111 pages
AWT & Swing: Anas Dange
PDF
No ratings yet
AWT & Swing: Anas Dange
41 pages
Week 9 Examples GUI - Layout - Examples
PDF
No ratings yet
Week 9 Examples GUI - Layout - Examples
9 pages
UNIT-I
PDF
No ratings yet
UNIT-I
87 pages
And Checkbox.: Aim (1) :-Design An Applet/application To Create From Using Text Field, Text Area, Button
PDF
No ratings yet
And Checkbox.: Aim (1) :-Design An Applet/application To Create From Using Text Field, Text Area, Button
16 pages
Jpr Programs
PDF
No ratings yet
Jpr Programs
34 pages
IT-PF-01-UNIT-8-1
PDF
No ratings yet
IT-PF-01-UNIT-8-1
33 pages
Unit1-Swing
PDF
No ratings yet
Unit1-Swing
78 pages
12review (GUIBasics)
PDF
No ratings yet
12review (GUIBasics)
4 pages
ADVANCE JAVA TECHNOLOGY
PDF
No ratings yet
ADVANCE JAVA TECHNOLOGY
3 pages
Java Gui Intro
PDF
No ratings yet
Java Gui Intro
24 pages
JAVA UNIT-V NOTES
PDF
No ratings yet
JAVA UNIT-V NOTES
54 pages
Java Swing Tutorials For Beginners: Layout Manager
PDF
No ratings yet
Java Swing Tutorials For Beginners: Layout Manager
4 pages