100% found this document useful (1 vote)
175 views92 pages

AJP 22517 Lab Manual Practical No.1-12 - PolyInfo-MSBTE

Uploaded by

Aditya
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
100% found this document useful (1 vote)
175 views92 pages

AJP 22517 Lab Manual Practical No.1-12 - PolyInfo-MSBTE

Uploaded by

Aditya
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/ 92
Learning Material for MSBTE Student | Computer Engineering Group | We Provide: Micro Projects Solved Lab Manuals Semester 3 Semester 3 Semester 4 Semester 4 Semester 5 Semester 5 Semester 6 Semester 6 Syllabus Details Important MCQ Questions Semester 1 ETI 22618 Semester 2 BSC 22102 Semester 3 EST 22447 { Semester 4 MAN 22509 | Semester 5 AJP 22517 Semester 6 Important Question Banks MSBTE News/Updates Semester 3 Board Examination Semester 4 Exam Form Filling Semester 5 Academic Calendar Semester 6 Important GR Visit: https://polyinfomsbte.blogspot.com Copyright © Polyinfo-MSBTE. Alll rights reserved. ‘Advanced Java Programming (22517) mL. mL. v. VL vu. Practical No. 1: Write a program to demonstrate the use of AWT components, Practical Significance: Text Field, Text Area, Button, Checkbox, Radio Buttons(Check Box Group) are the AWT components. Used to design the GUI in java. A component is object having representation that can be displayed on the screen to interact with the user. Relevant Program Outcomes (POs) * Basic knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the computer group related problems. + Discipline knowledge: Apply Computer Programming knowledge to solve the ‘computer group related problems. «Experiments and praetice: Plan to perform experiments and practices to use the results to solve the computer group related problems. * Engineering tools: Apply relevant Computer programming / technologies and tools with an understanding of the limitations. _ * Individual and Team work: Function effectively as a leader and team member in diverse/multidisciplinary.teams. * Communieation: Communicate effectively in oral and written form. Competency and Practical skills To develop standalone applications The practical is expected to develop the following skills: 1. Able to design form using required AWT components 2. Able to understand the different Components available in AWT Relevant Course Outcome(s) Develop programs using GUI Framework AWT. Practical Outcome (PrOs) Write a program to demonstrate the use of AWT components. Relevant Affective domain related Outcome(s) 1. Follow precautionary measures. 2. Follow naming conventions. 3. Follow ethical practices. Minimum Theoretical Background AWT is a java programming language class library. Components are visible objects. that can interact with the user. Containers, (Frame, Panel, Applet) are used to hold components using ina specific layout. Using applet window, design following AWT components using addQ) method of ‘components class. Following, are some AWT components 1. Label: Creates a label that displays a string. # _ 2. ‘TextField Creates and accepts a single-line text fromuser. 3. TextAtea Creates and accepts multiple line tex. from user, aia ar at Teal an see | Frame (= new Frame (" Chectiyortevoug) j 1:7 ! = | Checebo inoue Cog = nec Checkbox(rroug Cf ! Eheckbox Group G Siew checicbox ere sate) adates) ; , abl) aaa(b2) jadates) , , ‘Advanced Java Programming (22517) Choice ‘The Choice class is used to create a pop-up list of items from which the user : may choose. When the user clicks on it, the whole list of choices pops up and new selection can be made. Choice defines the default constructor, which creates an empty list. To add a selection to the list, call add (). : VIII. Resources required (Additional) — : : Nil \ f : IX. Resources used (Additional) : Sr] Name of ; Broad Specification | Quantity | Remarks (Ifany) | No.| Resource comparey COUT af TESA en | BAS Gad | =e 2 foPEre Td | windows ~ to i = X. Program Code: Teacher must assign a separate program statement to group of . 344 students. : ee : 1. Write Java Program to show following output. : Applet Viewer: AppCho... Applet Applet started. Advanced Java Programming (2517) 2, State the difference between List and Choice control 3. Write the use of getSelectedltem() and getSelectedindex() for List. (Space for answer) Ana us: de Ano. WA Of QVAMNabte Choices A xO ngahad. ee TE0m@O kBE\eo>w rentcities extends Applet i nit = q tac List 1snew List (5 true) as |t1aaac > Tiaaa(* Pune") = Leaat > 1 aaat > li laaat > Lagat > Lagat > Lada t > aaa ) - Lagat , eda) i nit q List 1snew List (8, true) | 11-setBounds (90,90, 130,15092 aaa , Leaat 1 aaat » iiaaat Lagat in laaa¢ » aca(11) sat ayoit (nu) , 4¢ Wold paint ” saint , extends Advanced Java Programming (22517) n. nL IV. Vi. vu. it design simple calcula ical No. 3: Write a program to i ae with the use of Grid Layout. Practical Significance: A layout manager automatical possible to lay out Java controls by hand, too, to manually lay out a large number of components ily arranges your controls within a window. White i, you generally won't. It is very tedia,, Relevant Program Outcomes (POs) ae « Basic knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the computer group related problems, Discipline knowledge: Apply Computer Programming knowledge to solve th computer group related problems. ‘ * Experiments and practice: Plan to perform experiments and practices to use the results to solve the computer group related problems. Engineering tools: Apply relevant Computer programming / technologies and tools with an understanding of the limitations. * Individual and Team work: Function effectively as a leader and team member in diverse/multidisciplinary teams. * Communication: Communicate effectively in oral and written form. ‘Competency and Practical skills - To develop standalone applications ‘The practical is expected to develop the following skills: 1. Able to apply different layouts to Applet, Frame and Panel 2. Able to demonstrate the use of different types of Layout Manager Relevant Course Outcome(s) Develop programs using GUI Framework (AWT and Swing). Practical Outcome (PrOs) Write a program to design simple calculator with the use of GridLayout. Relevant Affective domain related Outcome(s) 1. Follow precautionary measures. 2. Follow naming conventions. 3. Follow ethical practices, Minimum Theoretical Background Layout Manager is a facility that determin when they are added to the container, implemented by all the classes of layout represent the layout managers, les how components should be arranged Layout Manager is an interface that is managers. There are following classes that Advanced Java. ning (2251 Layout Types = | a FlowLayout | GridLayout | BorderLayout | [ CardLayout || GridbagLayout f Te? ' ‘Understand the default layout for different containers such as Applet, Frame, Panel. a * = a Grid Layout is used to make a bunch of components equal in size and displays them in the e requested number of rows and columns. One component is displayed in each rectangle, The list of Coistructor for GridLayout are: re 1. GridLayoutO: creates a grid layout with one column per component in a row. 7 af 2. GridLayout(int rows, int columns): creates a grid layout with the given rows and columns but no gaps between the components, 3., GridLayout(int rows, int columns, int hgap, int vgap): creates a grid layout with ~ the given rows and columns along with given horizontal and vertical gaps if we give setLayout(null) the default layout is disabled.then we have to use setBounds : method to layout the components: | VILL Resources required (Additional)— Nil TX. Resources used (Additional) Sr] Name of Broad : [Se eines Specification | Quantity | Remarks (Ifany) | Coraguey | evoce ssor 19} | 1 | sastem Ram - Yue]! in X. Program Code: Teacher must assign a separate program statement to group of ‘3-4 students. 1. Write java Program to Demonstrate Grid of S* 5 5 Sips 2 Wien poppanic denny Ths Nupba BIND SS AM Pore, JOYA. A624. % 5 ics OM ASS wy extends. Prame 8 [immer] Amport Java.awt-*7 extends Fram ‘ sridsby5 () { for (integer imi; see id (new Button (i.tostringQ)) setTitle( 1 Size (400,500) 7 jetvisible true) ? etLocation (200, Layout (new Gridl Lic stati rgs) new Gridsby5() , ) Arngort Sava aust.ce} Amport Java. appreys % 5 Qubuic race Burtong | extends Ageret Sutton b6, bt, bt, b3, b4, bbe, bribe, bF j Pabsic void Lait O bo = new Button (80) } Bi = ned Butran 1") 5 b2 = Nets Bukon O23 b3 = new Betiag C3" 5. bass new! Raw AH GEN) S ota yar eee cea bs = neo gution UE > ah ih bE = geo Rutron (6 ")5 7 neo Button U1") 5 resell iz bz = Neo guttea UP"); u bg = ned Buttoa CO9"5) 5 : 10 ih 3 odd (bo); uf ee pack Ti a 8 tT ie clase Button? extends Applet Button b0,b1,b2,3,b4,5, re bli inito ‘ bisnew Button baenew Button ( bacnew Button ( | baenew sueton( bsenew Button ( bé=new Button ( besnew Button ‘ aa (80); eT x ada(bi) ¢ fads (ba): add tba); ada (bs); faa tbe) aa (B7) + ae (59) + ad (b9) + Advanced Java Programming (22517) 3 Pe + _lLimport java.auot * j iis i UbWE Class RoyderDeomi! «i : ease seanid void main (sting orgel J) ot jee SC Frame §= new Frame () j : | Fseryisibie Cte) fs 3 F SetSize (G00, 600) j Cd ok ‘ rd F.seylayous (new BorderLaysiat, Qos ed LRurzon biz neo gurton CMR) J ts Button be = feu: Bettie aL (Sei) jae LRutton b2 = neo Burda CEA) wis [Buyon bur neo Button C Were): | Rutten bs = ned Buried! G “ee G.odd (bi, gorderloyout. North a F-odd (bz, porder Layout. SOOT IS odd (63 Border Layout. EAST 7 F-odd (64, Bovdevlajou. WEST) 5 | 00d (bS , Border Layout. CENTERS xi Oo. —— > || import Java: cst 9% 7 Arngort Java. appret.% 5 FUBNC C1ASS GridSazlayousDemo extends Applet ie Noi thee Lobel Ut = aed Label (Name) 7 TFextBied tf = ned rextfretd Co); add CAV) iF add CF) 5 ui Label Az = new Label CO Comment "i Textiyea tar Nevo Textfrrea(6,15)) odd (42) 5 add (t9)5 Burton bt > neo Button Submit!) 5 od (b1) 5 TFT ao wae econ inert jane a itayoucSuampie( i eoescontent ane) bireaiactiontsstener (ents) Ba asmetionListenr (his) betes rome tal adit 3) 0.4887, Ba) ened, 13) i siic oid muint@tringt] arsed youn cen castor ctvioise Gave) : 3; u ! ‘advanced Java Programming (22517) mL. nL Iv. VL Vu. Practical No. 5: Write a program using AWT to create a menu bar where menu bar contains menu items such as File, Edit, View and create a submenu under the File menu: New and Open. Practical Significance: ‘The Menu Bar lets the user to select different menu options from the list of available ‘menu items and perform operations on the selected menu item. Relevant Program Outcomes (POs) + Basic knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the computer group related problems. + Discipline knowledge: Apply Computer Programming knowledge to solve the computer group related problems. + Experiments and practice: Plan to perform experiments and practices to use the results to solve the computer group related problems. + Engineering tools: Apply relevant Computer programming / technologies and. tools with an understanding of the limitations. * Individual and Team work: Function effectively as a leader and team member in diverse/multidisciplinary teams. * Corimunieation: Communicate effectively in oral and written form. Competency and Practical skills To develop standalone applications ‘The practical is expected to develop the following skills: 1. Able to develop Menu, Menu Bar and Menu Items 2. Able to write a program using Menu Bar and assign shortcuts Relevant Course Outcome(s) Develop programs using GUI Framework (AWT and Swing) Practical Outcome (PrOs) Write a program using AWT to create a menu bar where menu bar contains menu items such as File, Edit, View and create submenu under the File menu: New and Open, Relevant Affective domain related Outcome(s) 1, Follow precautionary measures, 2. Follow naming conventions, ‘ 3. Follow ethical practices, ' Minimum Theoretical Background A top-level window can have a menu bar associated with it. A menu bar displays a list of top-level menu choices, Each choice is associated with a drop-down menu. This concept is implemented in the AWT by the followi 5 ere by the following classes: Menu Bar, Menu, ‘Maharashtra state Board of Technical Education. >= ‘Advanced Java Programming (22517) MenutremDemo qeneo Menutlem Demo 7 asexTine (menubas'); A SAVIS be (evue) j | Gomes tscor noo} 5 XI. Result (Output of Code): XII. Practical Related Questions Note: Below given are few sample re ‘for reference. Teacher must design ‘more such questions so as to ensure the achievement of identified CO. 1. Write the use of setEnabled( method ~ 2. Write the procedure to assign shorteut key to the Menu Item 3. Write a syntax and use of addSeparator() method + -(Space for answer) a acaeo Saale ene « =x Menuttenben0() nero) Menuttem bienew Men vs nated (faze peasa(s) . = 1 4 main(steing #1) Menultenbens amnew Menuttenbeno() scesttitiet > ene ; , ‘Advanced Java Programming (22517) I. mL. Iv. Vi. Practical No. 6: Write a program using swing to display a ScrollPane and JComboBox in an JApplet with the items - English, Marathi, Hindi, Sanskrit. Practical Significance: The Swing Components are very useful to design interactive application and it provide rich look and feel to the components. Swing components are light weight and platform independent. Swing supplies additional controls such as TabbedPane, ScrollPane, Trees and Tables. JFrame and JApplets are used to design windows and web applications. Relevant Program Outcomes (POs) * Basic knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the computer group related problems. Discipline knowledge: Apply Computer Programming knowledge to solve the computer group related problems. Experiments and practice: Plan to perform experiments and practices to use the results to solve the computer group related problems. Engineering tools: Apply relevant Computer programming / technologies and tools with an understanding of the limitations. Jeg Individual and Team work: Function effectively as-a Jeader and team member in diverse/multidisciplinary teams. * Communication: Communicate effectively in oral and written form, Competency and Practical skills To develop standalone applications using swing components The practical is expected to develop the following skills: 1. Able to Implement the JComboBox and JScrollPane 2. Able to write the program using JApplet/JFrame Relevant Course Outcome(s) Develop programs using GUI Framework (AWT and Swing) Practical Outcome (PrOs) Write a program using swing to display a SerollPane and JeomboBox in an Japplet with the items ~ English, Marathi, Hindi, Sanskrit. Relevant Affe domain related Outeome(s) 1. Follow precautionary measures, 2. Follow naming conventions. 3. Follow ethical practices, Minimum Theoretical Background 2 Fundamentals to swing is JApplet class which extends Applet. JApplet Supports various panes such as content pane, glass pane and the root pane, When adding a component to an instance of JApplet, call add () method -for the content pane of JApplet object. Poke oo Maharashtra tate Board of Technical Education T, wD) at Ih imgoat Sova. awt event %5 \mpork java. aut, 5 Aengort Javan. Seoing 7 —___lPurric eros 0 {nagrementt ‘Themlistenere Trrame (wy j E Teen Gir "Coco | mit lemaa Diavet by ki ComboBoxtxamere () fr= new SFrame Oj \o= new Tabet String lames LI= {'Sercgurr’ pune’ “Sangayore’y mumbai” |i C> New Jumbswox (name) f GoddtyemUganey his ) 5 a re add (c) j i Fradd (b)s hi per Fre Seflayout [neve Poolayous ©); I Fe Sex sire 600,600) j | She er & Seavisihie (ferns) 5 VEV@OROS|@O>e ifferentstates ( of SFrane (i : : : i ‘ ;ComboBox chanew JComboBox (5) 7 a Bounds ¢ 180,20) 5 add (cb) jetLayout (nul) ; jet S1z6(500, 400) leet Visible (true) , public static void main args) { , , TEVGO KE example { te static void GUE f.sersizet vs getcontentPane () sete t (02a , aco) LLBAR ALWAYS) Advanced Java Programming (22517) T. m1. vu. Maharashira state Board of Technical Education Practical No.7: Write a program to create a JTree. Practical Significance: Tree is used to represent the hierarchical view of the data. The tree control shows the data in tree like structure such as root and its leaves, Relevant Program Outcomes (POs) + Basic knowledge: Apply knowledge of basic mathemati engineering to solve the computer group related problems. * Discipline knowledge: Apply Computer Programming knowledge to solve the computer group related problems. 5 Experiments and practice: Plan to perform experiments and practices to use the Fesults to solve the computer group related problems. + Engineering tools: Apply relevant Computer programming / technologies and tools with an tindferstanding of the limitations. + Individual and Team work: Function effectively as a leader and team member in diverse/multidisciplinary teams. * Communication; Communicate effectively in oral and written form, sciences and basic Competency and Practical skills To develop standalone applications using swing components ‘The practical is expected to develop the following skills: 1. Able to implement the JTree with its methods. 2. Able to write the program using JTree. Relevant Course Outcome(s) Develop programs using GUI Framework (AWT and Swing) Practical Outcome (PrOs) Write a program to create a Jtree Relevant Affective domain related Outcome(s) 1. Follow precautionary measures. 2. Follow naming conventions. 3. Follow ethical practices. Minimum Theoretical Background MTree is a complex component. It has a ‘root node’ at the top most which is a parent for all nodes in the tree. It inherits JComponent class, Constrtuctors of JTree class JTree(Hashtable ht) : ‘The first form creates a tree in-which each element of the hash table ht is a child node. ie ‘Tree(Object objf}): Each element of the array obj isa child node. JTree(TreeNode tn):The tree-node tn is the root of the tree, Amgort Savax. Seong. 7) Amport Java. Seoing. tree: ey Amport Java. aut. Ki} Kuwric Crass Thee bxaenge Qubuicrvoid main (String Longs) L TWAmMe _TFramemain = aew I¥axame Cj TY¥rame main. Setvisible Ayue) j T¥ramemain.sepfize Coo, oo) § Deraurtmurabreyreedode cvootwWode = nec Sefautt musrabie- i rreenode (YEndia’) 7 - SefaurtMurabierreentede maborashiva lode = ned e | fe Defaurtiuravreyree node (' traharashiva' ye ___ arootntode ado (maharashtra node )5 jrothniode = nerd DefaurMurablerpree tode Co guirvath") ; | reootpede -add (auinorhrede Ij Defaurtmurabiepreentode mumbaisubnode 2 new | Defaurt mutable tree pode C8 waumbai "Jj ____j Defauy mutabietree rede aes = new. DeCaurrmurabepreeniode C Pune") 7 Defaurywnurabter-ree ode ashi kSubplode = nec DeCaurtmusobrey-ree nlod e Defourtmusablepree pode nage urSulorled@ = DeCourttmuablePreentedé Crag mahoroshiror\ode - add Cnumbat su subr makarrash'o ode .add Caune Subs Subpbode ) 3 moherathtra todt-ade Cnashiresub itede )j_ Sockets. ode. oda Ce e nag pee ae ? sample . oid: minitciog td om) rane Jeranetatn = now JFrane() TPeanchain,setviasbLe (eve) sPranchaineetSiae(400 (00) Footlods eda (guieatiMoe) Mutabletreeiode mnbaiublode = new Defaultitucablenceetode Mutablafreslods punesubNode = new Defaultiitanletrsenode sree tree = new Ieee rootade) Frame. aaa (eres) , , -—_Advanced Java Programming (22517) - Dmumoa | | Brune LD Nashik |B wasbur Di cujramn Figure 9 XI. Result (Output of Code): XII. Practical Related Questions Note: Below given are few sample questions for | omen Teacher must vie 7 ‘more such questions so as 10 ensure the achievement of identified CO. 1. State the use of JTree in Swing. 2. State the use of getPathForLoeation() method. 3. List different packages used to irnplement JTree.programs. (Space| for answer) ‘Maharastra tate Board of Technical Fducation Zoe pen aae TEV@OROS|eO>e Advanced Java Programming (22517) I. m1. Iv. VL. vu. Practical No. 10: Wi ‘ea program to demonstrate status of key on Applet window such as KeyPressed, KeyReleased, KeyUp, KeyDown. Practical Significance: A KeyEvent is generated when keyboard input occurs. When key is pressed, released or typed, key event is generated. Students will be able to understand the method to register an object and handle various key of Keyboards. Relevant Program Outcomes (POs) + Basic knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the computer group related problems. Discipline knowledge: Apply Computer Programming knowledge to solve the computer group related problems. Experiments and practice: Plan to perform experiments and practices to use the results to solve the computer group related problems. Engineering tools: Apply relevant Computer programming / technologies and tools with an understanding of the limitations. Individual and Team work: Function effectively as a leader and team member in diverse/multidisciplinary teams. * Communication: Communicate effectively in oral and written form. Competency and Practical s! Using this Practical, students will be able to generate able to implement various methods for appropriate execute programs accordingly. fferent events .Also, they are listener class and write and Relevant Course Outcome(s) * Handle Events of AWT and Swing Components. * Develop programs to handle events in Java Programming. Practical Outcome (PrOs) oe Write a program to demonstrate status of key on Applet window such as KeyPressed, Key Released, KeyUp, and KeyDown Relevant Affective domain related Outeome(s) 1. Follow precautionary measures. 2. Follow naming conventions. 3. Follow ethical practices. ‘Theoretical Background : ; When keyboard input is occurred, a KeyEvent is generated, There are mainly three types of key events that are recognized by integer constants as follows: KEY_PRESSED, KEY_RELBASED, KEY_TYPED When key is pressed or released, first two events are generated. When character is pressed, the last event occurs, All Keys do not generate character, E.g. Shift Key ‘Maharashtra state Board of Technical Education 3 ‘Advanced Java Programming (22517) ce 2k. ekkey Chay OF wwsrotur (& Wye TreROA AA 6) ike Siecle He Vaid gaint (Grvath'es 9) MSG = DRY Presred «1 ach y 8 dvaeString Consg, 10 ,10) f y XI. Result (Output of Code): XII. Practical Related Questions , Note: Below given are few sample questions for reference. Teaclier ‘must design more such questions so as to ensure the achievement of identified CO. : 1. Name any four Event Listener interfaces. oa 2. State the situation when all three events of KeyListener interface are generated? (Space for answer) TEV@OROS|eO>e ntExanplel extends Applet implements KeyListener ® insta ‘ 4 keyReleasea KevEvent i) () a key eno = k.getteyenar() 1 tng msg, 10,10) Peed STA \mgort Jovan owt; Amporrt. tow. rOppret. Ry Ameort Jona: AW: ent, % — Case key Evertbxampre extends Appiet Amen Stmng msg cS | panic void wit O | SS CONES ae : See Cexzvents 4) Ve key = Ke genencode. Oy Switth Ckey) case kejtvene. VR_EL ES ita | msg = msgx Fi" 5 : Wyrealk 5 f Case KeyEvent.vie~ F2i || son 54 2 msg X* F2" j Nyveak j Case weyivent. oF Fg: msg. = msg a” re Ta Lee" Tesenies I] Case wey Evento vic vhf Lal meee ee ULF | poreot, $ Case Keytvert .vK- Donn ¢ msg 2 MSg x“ Dorin") beak 5 erepaint OF pia, 779 es cTeeg b gubsit Noid nee (wey Event_k) Ty pubic void Keytyeed’ (vepevent =) sli ae Void paint (brraphres en Sd (esq, torte) jg ty Advanced Java Programming (22517) 2. void mouseEntered(MouseEvent me) 3. void mouseExited(MouseEvent me) 4. void mousePressed(MouseEvent me) 5. void mouseReleased(MouseEvent me) In the similar way we can handle the events when mouse is moved or dragged. The MouseMotion Interface defines the following methods. 1. void mouseDragged(MouseEvent me) 2. void mouseMoved(MouseEvent me) VIII. Resources required (Additional)— Resources used (Additional) Sg perso Broad Specification | Quantity | Remarks (If any) cy | CemQuaeN | preter 3 1 ai i SUSE RA - Hag Program Code: Teacher must assign a separate program statement to group of 3-4 students. 1. Debug the following Program code and write the output. import java.applet Applet; import java.awt.*; import java.awtevent.*; /* */ public class MouseDemo extends Applet implements MouseListener Label I; public void init() setLayout(null); new Label("Hello’Mouse"); L.setBounds(50,150,200,100); ; add(); — > soe void mousePressed(MouseE vent) t i nee fext("Mouse Pressed no. of clicks:" + ai Heaton re gedxO 2" ege¥O) es i 1 Faget TEV@OROS|eO>e Tat Bp 3 4 ‘ Advanced Java Programming (22517) XIII. Exercise 1. Write a program to change the background color of Applet when user performs events using Mouse 2. Write a program to count the number of clicks performed by the user in a Frame window v3. Write a program to demonstrate the use of mouseDragged and mouseMoved ‘method of MouseMotionListener (Space for answer) Amgort Java. owt. %) ~\engort. Sova. apie t 2 f bli i Am port java. out events rps fabue_crasr MouseconatDemno saitends Agpret Lanpremneats mouse Listener x iron — add Mouser ener Ore rc) 5 ei siciel Ant tount 20) a Pubic void init O wl fewer Re ibys = xe ae im a - Rubuc Vor use CAC ened Seve se) Coun) £4900.) 5: abated | Show Status ees ca Alene Crale ne ee cregaint 07 . * OOF badae Sambal pic Void mouse Entered (mousetvent me) or gs jOUsemol oe (tis ) I Set Size (302, 300) / Seflayout Cau) j 5 Sehvisibre CtT4ed; Wii € Void mous house Evi ea ig _ Geraphics JF get@raghichOj 4 gasetCoror (Color BLUE) J _gefitrovai (e-gotx O, €-geky 0, 20,20 ) j . pesos void Mousemoyed (MoufeEvent € ) ie i Pubric static void main (String CI ange) qnew Mmousetrasged Moved Oe ax import import import ja actice TEV@OROS|eO>e java-apple lase BackgroundColorDemo extends Applet Amplements MouseHfotionListener A anit otionListener (this) ; mouseDragged (MouseEvent me) st Background (Color.blue) + repaint? ‘ pane censey d(MoureBvent me) -eeount) red MouseBvent ne) tediMousezvent me) A¢ousetvent me) (eousetvent me) Gmport java.awt.*; import jJava.awt.c + public MouseDraggedandMoved MouseDraqgedandMoved () { extends Frame implements Mi addouseMot ionbistener (this) ; jetSize (300,300); et Layout (nal) ; jet Visible (true) ; ? lic void mouseDragged(Mousezvent e) ( raphics gagetGraphics () ; g.setColor (Color.BLUE) ; g-filloval (e.getX() ,e.get¥ () ,20,20); > public void mouseMoved(MouseEvent ¢) {? public stal 4 main(stringl] args) { new MouseDraqgedandMoved () ; ? wseMoti Advanced Java Programming (22517) 7 Th. mL. ay ve VL. Competency and Practical skills Practical No. 12: Write a program to demonstrate the use of ‘JTextField and JPasswordField using Listener Interface. Practical Significance: A password is used to authenticate the user to gain the access to website application or device. The TextField control is used to accept the input from user. An interface is "used to implement the methods as per the users requirements and achieve the concept ‘of multiple inheritance in java, Relevant Program Outcomes (POs) * Basie knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the computer group related problems, : Discipline knowledge: Apply Computer Programming knowledge to solve the computer group related problems. * Experiments and practice: Plan to perform experiments and practices to use the results to solve the computer group related problems. . Engineering tools: Apply relevant Computer programming / techriologies and tools with an understanding of the limitations, Individual and Team work: Function effectively as a leader and.team member in diverse/multidisciplinary teams, : + Communication: Communicate effectively in oral and written form, ~The practical is expected to develop the following skills: 1, Able to develop an application using JTextField 2. Able to develop an application using JPasswordField Relevant Course Outcome(s) Handle events of AWT and Swing Components Practical Outcome (PrOs) Write a program to demonstrate, the use of JTextField and JPasswordField using Relevant Affective domain related Outcomes) 1, Follow precautionary measures. 2. Follow naming conventions. 3. Follow ethical practices. VIL Minimum Theoretical Background a JPasswordField: of FE : ichdllowh the’ wter ta hier trerpoe exeth Seer ntact Toxo slate ae ey oe # call ‘Advanced Java Programming (22517) import javax public class ng.*7 jordFieldDemo public static void main(Stringf] args) { JFrame f=new JFrame ( Nia UPasswordField valu a0; — Label lisnew JLabel ( ": etBounds (20,100, 80,30); value. setBounds (100,100, 100,30) 7 £.add (va £.add (11); TsetSize (300,300) £.setLayout (null) ; £.setVisible (true) ; , ?

You might also like