1 00:00:00,780 --> 00:00:10,200 In this lecture we are going to write the piece of code that will make the browser work. 2 00:00:10,380 --> 00:00:19,890 We added a web browser component which is this component here that is going to do a lot or most of the 3 00:00:19,890 --> 00:00:24,420 heavy lifting for the application. 4 00:00:24,420 --> 00:00:26,570 So what we're trying to achieve here. 5 00:00:26,580 --> 00:00:35,510 This combo box here is where B you are for the web address will be written. 6 00:00:36,090 --> 00:00:48,450 So when the user presses enter in that location we want the you are real or the address to load. 7 00:00:48,450 --> 00:00:48,870 All right. 8 00:00:48,870 --> 00:00:57,630 So to make that happen click on this combo box here and click on this icon that looks like a lightning 9 00:00:57,630 --> 00:00:58,460 bolt. 10 00:00:58,770 --> 00:01:02,660 That is some event known as the event. 11 00:01:02,790 --> 00:01:04,850 So we're going gonna scroll down. 12 00:01:06,360 --> 00:01:15,410 It's usually in alphabetical order so I'm gonna scroll down to see the key down event here and the event 13 00:01:15,570 --> 00:01:21,980 is the action that a visitor performs on an application or a web page. 14 00:01:22,080 --> 00:01:27,070 So when if you press click or enter that is an event. 15 00:01:27,720 --> 00:01:33,520 So this is the event we want to target key down. 16 00:01:33,570 --> 00:01:40,650 So what we're gonna do we're going to double click on this and that should create a Skeletor code for 17 00:01:40,650 --> 00:01:44,140 us to this code here is a method. 18 00:01:44,220 --> 00:01:50,250 So this we have to create the code in here that will respond to this method. 19 00:01:50,280 --> 00:01:59,820 This method is a key dance when the when that key is pressed it would trigger the function or the code. 20 00:01:59,850 --> 00:02:03,320 We are going to write in here. 21 00:02:03,510 --> 00:02:12,490 So this method we will get called when ever the key is pressed. 22 00:02:12,900 --> 00:02:24,390 So but we need a way to find out if a key has been pressed or not on the keyboard. 23 00:02:24,390 --> 00:02:33,480 So we're going to specify a method that would check whether the enter the enter key was pressed and 24 00:02:33,570 --> 00:02:44,160 if it was we going to make it try to load whatever you are real address inside the combo box so we can 25 00:02:44,160 --> 00:02:48,380 solve two problems using the method. 26 00:02:48,390 --> 00:02:54,900 So we need we know which key was pressed because will ultimately get the key. 27 00:02:54,900 --> 00:03:03,120 This event here okay we'll get that object that object will be called using this e the e is the event 28 00:03:03,570 --> 00:03:11,820 it is what tells us the key has been pressed so to check that I'm going to write a conditional statement 29 00:03:11,820 --> 00:03:14,310 known as an if and so I'm going to say if 30 00:03:17,340 --> 00:03:19,080 I'm referencing this key here. 31 00:03:19,080 --> 00:03:22,020 Now this event say if e dot 32 00:03:25,110 --> 00:03:36,360 key code which is this is a cause two single equals two means you are signing something double equals 33 00:03:36,360 --> 00:03:38,510 two means you're checking something. 34 00:03:38,550 --> 00:03:42,690 So if that is equals two keys 35 00:03:46,220 --> 00:03:52,590 dot I need to specify the type of key that enter. 36 00:03:52,750 --> 00:03:59,740 So if that is equals to the enter key I need to specify what will happen. 37 00:03:59,770 --> 00:04:06,640 So I need to inside this parentheses here I need to specify another code. 38 00:04:06,640 --> 00:04:14,470 So the code I'm going to specify I'm going to call the web browser component that we added which is 39 00:04:14,470 --> 00:04:19,770 this one here and there's a method that you can attach to that. 40 00:04:19,810 --> 00:04:26,670 If I click on the dot it would give me a list of different things the intelligence would give me a guide. 41 00:04:27,190 --> 00:04:30,550 So there should be a method called navigate. 42 00:04:31,510 --> 00:04:32,230 OK. 43 00:04:32,260 --> 00:04:37,230 So if I scrolled through there should be a navigate method. 44 00:04:37,230 --> 00:04:38,220 There you go. 45 00:04:38,280 --> 00:04:43,070 That is a method if you put the tooltip he tells you what that does. 46 00:04:43,120 --> 00:04:51,150 So be navigate and empowerment he these are passing the combo box combo box. 47 00:04:51,310 --> 00:05:00,360 This is the name of the combo box because it's going to be a text that's passed in our typing text. 48 00:05:01,100 --> 00:05:01,670 OK. 49 00:05:01,690 --> 00:05:06,210 And then finish that off with a semi colon. 50 00:05:06,280 --> 00:05:12,910 So whenever you see the yellow strips it means your code has not been saved so I just save it by clicking 51 00:05:12,910 --> 00:05:16,350 on this save all tab here. 52 00:05:16,360 --> 00:05:20,100 So here we've got the navigate method. 53 00:05:20,170 --> 00:05:27,160 So if the enter key is pressed this is just an if statement showing that if the entire key is pressed 54 00:05:27,940 --> 00:05:38,620 the navigate we can use it navigate method of which belongs to this component here to control and load 55 00:05:38,890 --> 00:05:40,040 a web page. 56 00:05:40,210 --> 00:05:47,800 That's what it's like to control and load the webpage attached to this component before we test the 57 00:05:47,800 --> 00:05:48,570 application. 58 00:05:48,580 --> 00:05:52,330 We need to hook up the order button. 59 00:05:52,330 --> 00:05:59,980 So if I go back to the design view and click on the back button 60 00:06:03,100 --> 00:06:05,540 and we go to the event. 61 00:06:05,560 --> 00:06:10,980 So the same thing here will look for. 62 00:06:10,990 --> 00:06:14,320 So the type of event would be a click event. 63 00:06:14,320 --> 00:06:24,340 So our double click on this and that will give me this skeletal code here for the button for the back 64 00:06:24,430 --> 00:06:25,290 button. 65 00:06:25,330 --> 00:06:28,230 So all I need to do is reference the web browser. 66 00:06:28,250 --> 00:06:31,960 So I'm just typing web typing that 67 00:06:35,000 --> 00:06:38,180 dot go 68 00:06:43,100 --> 00:06:52,310 back Okay so we don't go back and then because it's a method we need to put parentheses. 69 00:06:52,310 --> 00:06:56,990 That's it for the back button to go back to the design. 70 00:06:57,070 --> 00:07:00,930 We go to the forward do the same. 71 00:07:01,430 --> 00:07:11,900 We'll look for the Click event double click and it should open up a skeleton called I mean double click 72 00:07:11,900 --> 00:07:12,870 on that. 73 00:07:12,870 --> 00:07:13,330 They go. 74 00:07:13,350 --> 00:07:15,050 So do the same thing here. 75 00:07:15,050 --> 00:07:21,830 Just come here to web browser one to a dot 76 00:07:24,440 --> 00:07:25,460 go forward 77 00:07:28,550 --> 00:07:29,750 parentheses 78 00:07:32,270 --> 00:07:35,980 and that's so that's it for that one. 79 00:07:36,050 --> 00:07:45,830 One more button go here click on the go button again come to the event double click do the same thing 80 00:07:46,850 --> 00:07:53,390 web browser one and this time we're just going to attach 81 00:07:55,880 --> 00:08:00,350 the DOT navigate method 82 00:08:03,110 --> 00:08:07,940 and just end that with a semicolon. 83 00:08:08,270 --> 00:08:16,850 So for the go button we passing the same parameter which is a combo box dot text which is the same we 84 00:08:16,850 --> 00:08:18,060 did here. 85 00:08:18,060 --> 00:08:20,420 So we've got some yellow strip. 86 00:08:20,450 --> 00:08:26,900 We just need to save our code and we can test our application. 87 00:08:28,260 --> 00:08:29,230 OK. 88 00:08:29,240 --> 00:08:38,660 So let's test our application so click on Start to start testing Hargis expand that a little bit 89 00:08:41,990 --> 00:08:43,310 make that a bit bigger 90 00:08:45,930 --> 00:08:47,050 OK. 91 00:08:47,190 --> 00:09:01,690 So let's go to a typing WW dot BBC dot com and click go hopefully. 92 00:09:01,770 --> 00:09:02,400 There you go. 93 00:09:02,430 --> 00:09:06,670 So we've got BBC our browser is working. 94 00:09:06,670 --> 00:09:07,240 There you go. 95 00:09:09,450 --> 00:09:17,070 So if you if you're getting a result from your search well done that means your web browser is working 96 00:09:17,550 --> 00:09:18,720 as designed. 97 00:09:18,780 --> 00:09:20,900 Congratulations. 98 00:09:20,910 --> 00:09:23,610 That's it for this lecture. 99 00:09:23,610 --> 00:09:24,990 Thanks for watching. 100 00:09:24,990 --> 00:09:25,790 Bye for now.