In this lecture we are going to write the piece of code that will make the browser work.
We added a web browser component which is this component here that is going to do a lot or most of the
heavy lifting for the application.
So what we're trying to achieve here.
This combo box here is where B you are for the web address will be written.
So when the user presses enter in that location we want the you are real or the address to load.
All right.
So to make that happen click on this combo box here and click on this icon that looks like a lightning
bolt.
That is some event known as the event.
So we're going gonna scroll down.
It's usually in alphabetical order so I'm gonna scroll down to see the key down event here and the event
is the action that a visitor performs on an application or a web page.
So when if you press click or enter that is an event.
So this is the event we want to target key down.
So what we're gonna do we're going to double click on this and that should create a Skeletor code for
us to this code here is a method.
So this we have to create the code in here that will respond to this method.
This method is a key dance when the when that key is pressed it would trigger the function or the code.
We are going to write in here.
So this method we will get called when ever the key is pressed.
So but we need a way to find out if a key has been pressed or not on the keyboard.
So we're going to specify a method that would check whether the enter the enter key was pressed and
if it was we going to make it try to load whatever you are real address inside the combo box so we can
solve two problems using the method.
So we need we know which key was pressed because will ultimately get the key.
This event here okay we'll get that object that object will be called using this e the e is the event
it is what tells us the key has been pressed so to check that I'm going to write a conditional statement
known as an if and so I'm going to say if
I'm referencing this key here.
Now this event say if e dot
key code which is this is a cause two single equals two means you are signing something double equals
two means you're checking something.
So if that is equals two keys
dot I need to specify the type of key that enter.
So if that is equals to the enter key I need to specify what will happen.
So I need to inside this parentheses here I need to specify another code.
So the code I'm going to specify I'm going to call the web browser component that we added which is
this one here and there's a method that you can attach to that.
If I click on the dot it would give me a list of different things the intelligence would give me a guide.
So there should be a method called navigate.
OK.
So if I scrolled through there should be a navigate method.
There you go.
That is a method if you put the tooltip he tells you what that does.
So be navigate and empowerment he these are passing the combo box combo box.
This is the name of the combo box because it's going to be a text that's passed in our typing text.
OK.
And then finish that off with a semi colon.
So whenever you see the yellow strips it means your code has not been saved so I just save it by clicking
on this save all tab here.
So here we've got the navigate method.
So if the enter key is pressed this is just an if statement showing that if the entire key is pressed
the navigate we can use it navigate method of which belongs to this component here to control and load
a web page.
That's what it's like to control and load the webpage attached to this component before we test the
application.
We need to hook up the order button.
So if I go back to the design view and click on the back button
and we go to the event.
So the same thing here will look for.
So the type of event would be a click event.
So our double click on this and that will give me this skeletal code here for the button for the back
button.
So all I need to do is reference the web browser.
So I'm just typing web typing that
dot go
back Okay so we don't go back and then because it's a method we need to put parentheses.
That's it for the back button to go back to the design.
We go to the forward do the same.
We'll look for the Click event double click and it should open up a skeleton called I mean double click
on that.
They go.
So do the same thing here.
Just come here to web browser one to a dot
go forward
parentheses
and that's so that's it for that one.
One more button go here click on the go button again come to the event double click do the same thing
web browser one and this time we're just going to attach
the DOT navigate method
and just end that with a semicolon.
So for the go button we passing the same parameter which is a combo box dot text which is the same we
did here.
So we've got some yellow strip.
We just need to save our code and we can test our application.
OK.
So let's test our application so click on Start to start testing Hargis expand that a little bit
make that a bit bigger
OK.
So let's go to a typing WW dot BBC dot com and click go hopefully.
There you go.
So we've got BBC our browser is working.
There you go.
So if you if you're getting a result from your search well done that means your web browser is working
as designed.
Congratulations.
That's it for this lecture.
Thanks for watching.
Bye for now.