alright so continuing on with our
directory and file chooses let's alright so continuing on with our
actually go back now we're going to directory and file chooses let's
actually change this directory chooser actually go back now we're going to
back to the file chooser again now we've actually change this directory chooser
already seen how to show an open back to the file chooser again now we've
dialogue which would do when the user already seen how to show an open
wants to open a file when the user wants dialogue which would do when the user
to save a file we actually call the show wants to open a file when the user wants
save dialog method instead of the show to save a file we actually call the show
open dialogue method so let's actually save dialog method instead of the show
do that now open dialogue method so let's actually
so first thing I'm going to uncomment do that now
the file chooser we're going to comment out so first thing I'm going to uncomment
the directory chooser and we're going to the file chooser we're going to comment out
do.... the directory chooser and we're going to
... do....
... ...
...now if you actually run this ...
i'm going to open the save dialog as you ...now if you actually run this
can see there and on a mac which is a i'm going to open the save dialog as you
little bit different to the how the pc can see there and on a mac which is a
and linux will work i can actually little bit different to the how the pc
choose a folder like my desktop i can and linux will work i can actually
then expand it out and I can go to choose a folder like my desktop i can
sub folder like test and I could save it then expand it out and I can go to
in there i can save it as... sub folder like test and I could save it
click on save and you can see that the in there i can save it as...
entire path has been now is showing click on save and you can see that the
there in the output so that's the path entire path has been now is showing
that has come back from the chooser if there in the output so that's the path
you just open that again notice here that has come back from the chooser if
also it's not open this time but its you just open that again notice here
save and that should be the same both also it's not open this time but its
for linux and windows as well save and that should be the same both
now depending on the operating system for linux and windows as well
that you're running on your might now depending on the operating system
also get a type field underneath the that you're running on your might
file name now i haven't actually got that also get a type field underneath the
here I don't see a file type i can see file name now i haven't actually got that
tags but on windows or linux you'll here I don't see a file type i can see
actually see the type fjeld and the file name tags but on windows or linux you'll
and that looks like a combo box and actually see the type fjeld and the file name
right now that combo box is actually and that looks like a combo box and
empty and typically an application will right now that combo box is actually
deal with files of a certain type and so empty and typically an application will
that it will actually expect to save deal with files of a certain type and so
files with a specific file extension that it will actually expect to save
that type fie food will display the file files with a specific file extension
extension or extensions that the that type fie food will display the file
application knows about now the field extension or extensions that the
isn't displaying anything because we application knows about now the field
have to set the extensions when isn't displaying anything because we
configuring the file chooser and again have to set the extensions when
this is applicable depending on which configuring the file chooser and again
operating system you're actually running this is applicable depending on which
on but we can still do that on a mac so operating system you're actually running
go back and do this and this will work on but we can still do that on a mac so
on all operating systems we can actually go back and do this and this will work
set the file chooses extension filters on all operating systems we can actually
so let's actually go ahead and actually set the file chooses extension filters
do that we do that by calling or get so let's actually go ahead and actually
the filters first by do that we do that by calling or get
calling get extension filters and then the filters first by
we're going to add to those extensions calling get extension filters and then
filters to the existing list so lets we're going to add to those extensions
actually go and have a look at how to filters to the existing list so lets
do that so... actually go and have a look at how to
... do that so...
... ...
.. ...
..
...and our file ...
statement.. ...and our file
...alright so now that statement..
we've done that you should be able to ...alright so now that
run this so lets actually see what gives we've done that you should be able to
us open now this time we've got the run this so lets actually see what gives
the file name and tags as the where before us open now this time we've got the
but notice this is actually showing the file name and tags as the where before
now we've got text and PDF and depending on but notice this is actually showing
your operating system this will show my now we've got text and PDF and depending on
show elsewhere and notice also when I'm your operating system this will show my
doing that the actual file name is being show elsewhere and notice also when I'm
changed automatically the end of the doing that the actual file name is being
file extension so i can put... changed automatically the end of the
... file extension so i can put...
actually saves us there as the full path ...
their so openeing that again we can select either actually saves us there as the full path
type and the file name appears and of their so openeing that again we can select either
course we can also click on cancel type and the file name appears and of
without to us selecting anything we get course we can also click on cancel
the cancellation coming through without to us selecting anything we get
alright so basically when we construct the cancellation coming through
an instance of extension filter we alright so basically when we construct
passed in a description of the files an instance of extension filter we
that have the file extension as the passed in a description of the files
first parameter and the file extension that have the file extension as the
as the second parameter now the first parameter and the file extension
description is a string as you saw there as the second parameter now the
in the code and I'll just that on description is a string as you saw there
the screen now the code on line 44 so in the code and I'll just that on
the descriptions are string as i the screen now the code on line 44 so
mentioned so you can be more than one the descriptions are string as i
word there and you saw that the type mentioned so you can be more than one
field gives you an option to select the word there and you saw that the type
type and again as I mentioned a few field gives you an option to select the
times this will look slightly different type and again as I mentioned a few
on Windows and Linux but essentially times this will look slightly different
it's the same concept in that you can on Windows and Linux but essentially
now choose the type of file that it's the same concept in that you can
you would be willing to save another now choose the type of file that
thing to note is its you would be willing to save another
important to know that the user is thing to note is its
limited to file names that have one of important to know that the user is
the extensions so in other words i can limited to file names that have one of
still go back and run this again open the extensions so in other words i can
now we can select PDF or whatever still go back and run this again open
I can change that to something else like now we can select PDF or whatever
maybe my ext for my extension and click I can change that to something else like
on save and we can get that path their but maybe my ext for my extension and click
note in the case of the mac it's on save and we can get that path their but
automatically appended the PDF that you note in the case of the mac it's
will just do that just to confirm we're automatically appended the PDF that you
going back to actually check this again will just do that just to confirm we're
text leave it on text and I put Tim there you going back to actually check this again
can click on that if you wanted to hide the text leave it on text and I put Tim there you
extension click on save and we've now got can click on that if you wanted to hide the
still the file name but with the dot txt extension click on save and we've now got
added to the end so closing still the file name but with the dot txt
it down so what's the use so of these added to the end so closing
file extensions why would we want to it down so what's the use so of these
actually use that these extensions file extensions why would we want to
filters well file extension actually use that these extensions
filters are useful because they limit filters well file extension
the files that the user sees now obviously filters are useful because they limit
we're using a saved dialogue at the the files that the user sees now obviously
moment but in the case of an open we're using a saved dialogue at the
dialogue we can actually limit the files moment but in the case of an open
that the user sees which can be dialogue we can actually limit the files
convenient for the user that the user sees which can be
when the file chooser is displaying a convenient for the user
directory with lots of files now when when the file chooser is displaying a
filters are set the file choose will only directory with lots of files now when
show files that have an extension that filters are set the file choose will only
matches the filter so basically we're in show files that have an extension that
this case where I am about to show you i'm matches the filter so basically we're in
just gonna run this one more time this case where I am about to show you i'm
what we'll do first is will change just gonna run this one more time
this let's get to change this out so what we'll do first is will change
we're going to temporarily stop the this let's get to change this out so
filters comment those out we're going to we're going to temporarily stop the
change the chooser from... filters comment those out we're going to
....I'm going to run change the chooser from...
that again back to main so we can run it ....I'm going to run
open at the moment we've go this that again back to main so we can run it
test folder we've got a zip file and mp4 open at the moment we've go this
and a PDF file lets actually cancel test folder we've got a zip file and mp4
out of that and will close the code down and a PDF file lets actually cancel
and we'll go back and we'll change this out of that and will close the code down
now and will uncomment this again what and we'll go back and we'll change this
we'll do is we're going to put zip now and will uncomment this again what
... we'll do is we're going to put zip
... ...
just run this again and now when we open ...
the dialogue should only see files of just run this again and now when we open
type zip now depending on your operating the dialogue should only see files of
system in the case of a mac now that we type zip now depending on your operating
specified zip and PDF only will actually system in the case of a mac now that we
highlight the files make them bold specified zip and PDF only will actually
the ones that are part of the filter and highlight the files make them bold
for selected zip if we go and select PDF the ones that are part of the filter and
you notice that it highlights the for selected zip if we go and select PDF
PDF file so it wilkl actually do either but in the you notice that it highlights the
case of windows or linux the chooser will PDF file so it wilkl actually do either but in the
only show files that match those case of windows or linux the chooser will
extensions so just a slight difference only show files that match those
in terms of the operating system but the extensions so just a slight difference
bottom line is you can't actually select in terms of the operating system but the
these other files in the case of the bottom line is you can't actually select
mack when I can select that one but if I these other files in the case of the
changes to PDF i can select the PDF and mack when I can select that one but if I
then i can't select the other ones so changes to PDF i can select the PDF and
bottom line here is it's a filter that then i can't select the other ones so
you can specify and there's the file bottom line here is it's a filter that
that actually selected and it ensures you can specify and there's the file
that the user can only select files of that actually selected and it ensures
that particular type that the user can only select files of
and as an example of why you want to do that particular type
that and as an example of why you want to do
so what happens when the user wants to that
open a file with an extension that so what happens when the user wants to
doesn't match one of those filters for open a file with an extension that
example the user might have downloaded doesn't match one of those filters for
file when they did so they gave that example the user might have downloaded
file a name with an extension that file when they did so they gave that
doesn't match any filters when they want to file a name with an extension that
open that file in the application they doesn't match any filters when they want to
could type the filename into the filename open that file in the application they
field because the filters don't could type the filename into the filename
prevent them from opening files with field because the filters don't
other file extensions but that's not prevent them from opening files with
really as convenient for the user to type other file extensions but that's not
the name so it's customary in that really as convenient for the user to type
situation to include a catchable filter the name so it's customary in that
with the open file chooser case the situation to include a catchable filter
worst that can happen is the user will try to with the open file chooser case the
open an unsupported worst that can happen is the user will try to
file in a real-world application we open an unsupported
could gracefully handle that case so file in a real-world application we
here's what i mean by that lets actually could gracefully handle that case so
look at the code for that controller so here's what i mean by that lets actually
that scenario with that third file type look at the code for that controller so
we add a new extension filter that scenario with that third file type
... we add a new extension filter
... ...
and if we run that click on open again ...
we've not got all files you can see and if we run that click on open again
in the case of the mac I actually got we've not got all files you can see
all three files available now i can in the case of the mac I actually got
click on that folder that I couldn't access all three files available now i can
previously and open the mp4 so click on that folder that I couldn't access
that's the catch all filter that just previously and open the mp4 so
added to our file chooser the other thing that's the catch all filter that just
to note here with the chooser is that added to our file chooser the other thing
we're not actually limited to one to note here with the chooser is that
extension so what I mean by that is lets just we're not actually limited to one
say we decide to add 1..... extension so what I mean by that is lets just
... say we decide to add 1.....
...so we can do something like ...
...so we can do something like
... ...
...and now if we run that ...
we opened again we can choose all image ...and now if we run that
files if their were image files their of which we opened again we can choose all image
their none they would be selected files if their were image files their of which
whether it's a jpeg jpg PNG or gif file their none they would be selected
so one last thing about file whether it's a jpeg jpg PNG or gif file
choosers and when we want the user to be so one last thing about file
able to select more than one file we choosers and when we want the user to be
open the file chooser using the show open able to select more than one file we
multiple dialogue method because it open the file chooser using the show open
actually returns a list of files so i go multiple dialogue method because it
back and just run this again open going actually returns a list of files so i go
to select all files and i can select a back and just run this again open going
mac i can hold down command to selected to select all files and i can select a
an additional file or its mac i can hold down command to selected
control on a windows machine or linux an additional file or its
machine is not allowing me control on a windows machine or linux
to do that so if I close this down and instead machine is not allowing me
of going back to controller instead of to do that so if I close this down and instead
the show open dialogue its show open of going back to controller instead of
multiple dialogue and notice how its the the show open dialogue its show open
returning a list of file so i can multiple dialogue and notice how its the
change the definition there to list... returning a list of file so i can
... change the definition there to list...
... ...
...try running this ...
now ...try running this
open this time i'm going to select all now
files and i can select all three files open this time i'm going to select all
just to see what it returns and you can files and i can select all three files
see we've got the path to the three just to see what it returns and you can
files that have been selected return to see we've got the path to the three
us so that we can work with multiple files files that have been selected return to
if that's something that's appropriate us so that we can work with multiple files
for your application if that's something that's appropriate
alright the last thing I want to cover for your application
now in this whirlwind tour this section is alright the last thing I want to cover
the internet or more specifically how to now in this whirlwind tour this section is
view web pages from within the javafx the internet or more specifically how to
application now client applications view web pages from within the javafx
often access the web for example application now client applications
sometimes clicking a help item will open often access the web for example
the system's default browser and sometimes clicking a help item will open
navigate to online help i'm going to the system's default browser and
take a look here at two controls to navigate to online help i'm going to
javafx controls the hyperlink and the take a look here at two controls to
webview so lets actually start with the javafx controls the hyperlink and the
hyperlink control and I'm guessing you webview so lets actually start with the
can probably figure out what that does hyperlink control and I'm guessing you
by its name so it descends from the can probably figure out what that does
labeled class so displays text but we by its name so it descends from the
use it when we want to display a link labeled class so displays text but we
going to add one to our grid pane so use it when we want to display a link
let's go back to sample .fxml going to add one to our grid pane so
will actually add one of these let's go back to sample .fxml
hyperlinks and just add it below the label will actually add one of these
that's going to be... hyperlinks and just add it below the label
... that's going to be...
... ...
just run that to see that it works so I ...
can see here we've got the javafx.com and just run that to see that it works so I
notice when my mouse goes over it it can see here we've got the javafx.com and
did actually changes to a link and notice when my mouse goes over it it
notice also the styling will change as did actually changes to a link and
well notice also the styling will change as
the texts is underlined as links often are or well
usually are in a browser but the texts is underlined as links often are or
the moment we click the link though you usually are in a browser but
can see that there's a notification that the moment we click the link though you
we have clicked it but nothing is can see that there's a notification that
actually happening we don't actually go to the we have clicked it but nothing is
webpage but you can see there that the actually happening we don't actually go to the
hyperlinks appearance has changed though webpage but you can see there that the
and that's because the hyperlink hyperlinks appearance has changed though
controls got three states unvisited and that's because the hyperlink
clicked and visited and the appearance controls got three states unvisited
of each state is different now if we clicked and visited and the appearance
want the appearance of a visited of each state is different now if we
hyperlink to revert back to that to a want the appearance of a visited
unvisited hyperlink we can call the set hyperlink to revert back to that to a
visited unvisited hyperlink we can call the set
method and pass in the value of visited
false now to have something happen when we method and pass in the value of
click the link we still would have to false now to have something happen when we
write an event handler and what that click the link we still would have to
should tell you is that we don't have to write an event handler and what that
go to a web page when a hyperlink should tell you is that we don't have to
controller is clicked we could instead open go to a web page when a hyperlink
a dialogue or change something on the controller is clicked we could instead open
user interface or perhaps display a dialogue or change something on the
contextual help within the application user interface or perhaps display
basically we can do whatever we want in contextual help within the application
that event handler to see how to do basically we can do whatever we want in
something like that let's close it down that event handler to see how to do
and let's go back to our controller something like that let's close it down
will go back to the fxml first will and let's go back to our controller
actually add an on-action so that will go back to the fxml first will
we can actually see that operation so actually add an on-action so that
put.... we can actually see that operation so
... put....
... ...
ok back here we're going to... ...
ok back here we're going to...
... ...
.... ...
....
...just try ...
running that click on the link this time ...just try
and you can see that our event handlers running that click on the link this time
showing...so what and you can see that our event handlers
do we actually want to do here well we want to showing...so what
show the web page located at www javafx do we actually want to do here well we want to
.com we can do this in two ways we can show the web page located at www javafx
open the system default browser or .com we can do this in two ways we can
alternatively we can actually add a web open the system default browser or
view controller to our user interface alternatively we can actually add a web
and display the contents of the web page view controller to our user interface
within the webview lets actually first and display the contents of the web page
view the webpage by opening the system's within the webview lets actually first
default browser view the webpage by opening the system's
so go back and change the code for that so default browser
what we'll do is we'll put a try in their so go back and change the code for that so
and do... what we'll do is we'll put a try in their
... and do...
... ...
so now if we go back and run this click ...
on the link and off-screen that link so now if we go back and run this click
actually opened and this is the page was on the link and off-screen that link
actually opened and actually forwarded actually opened and this is the page was
it to oracle.com and because if we go to www actually opened and actually forwarded
....it forwards to that it to oracle.com and because if we go to www
page ....it forwards to that
clearly the link work fine alright so page
now we know how to visit a web page clearly the link work fine alright so
using the system's default browser let's now we know how to visit a web page
actually look at how to display the using the system's default browser let's
contents of a web page within the actually look at how to display the
application using the webview control so contents of a web page within the
let's actually go back to our code to our application using the webview control so
fxml file lets actually start by let's actually go back to our code to our
adding a webview control to the grid fxml file lets actually start by
pane we will add it in the fifth row and we're adding a webview control to the grid
going to do.... pane we will add it in the fifth row and we're
... going to do....
... ...
you can see there's some evidence that ...
something there but i we can't really you can see there's some evidence that
see much at the moment certainly there's something there but i we can't really
no output but we haven't told it to do see much at the moment certainly there's
anything now depending on your operating no output but we haven't told it to do
system if you're running Windows or anything now depending on your operating
Linux you may not actually see anything system if you're running Windows or
because of the colors because that's Linux you may not actually see anything
because the default background color because of the colors because that's
of a webview is white and it doesn't because the default background color
have a border but on a Mac because of of a webview is white and it doesn't
the way they do the coloring you can have a border but on a Mac because of
actually see that but you probably find the way they do the coloring you can
that you won't see anything and your actually see that but you probably find
running those operating systems but we can that you won't see anything and your
then do is go back and add a reference running those operating systems but we can
for our web view to our controllers so then do is go back and add a reference
going to write the code first... for our web view to our controllers so
... going to write the code first...
... ...
...so now we run that ...
click on the link you can see it's ...so now we run that
trying to load and obviously we can click on the link you can see it's
expand a little bit further but we actually trying to load and obviously we can
got now a workable link we can actually expand a little bit further but we actually
navigate as we would normally do a got now a workable link we can actually
regular browser which is pretty cool alright I will navigate as we would normally do a
just close it down so that web regular browser which is pretty cool alright I will
engine is the powerhouse that does that just close it down so that web
drives the display of the webpage and we engine is the powerhouse that does that
can actually do a lot with it gives us drives the display of the webpage and we
access to the web pages document can actually do a lot with it gives us
model and we can even use that to access to the web pages document
execute JavaScript and what I suggest model and we can even use that to
you do if you're interested in that is execute JavaScript and what I suggest
referred to the documentation for web you do if you're interested in that is
engine and i'll just bring that up on referred to the documentation for web
the screen very useful to check that out engine and i'll just bring that up on
and find out more about that the screen very useful to check that out
alright so that actually concludes our and find out more about that
tour of a few more javafx features and alright so that actually concludes our
obviously i still haven't covered tour of a few more javafx features and
everything possible with that java fx obviously i still haven't covered
has to offer because it's so everything possible with that java fx
comprehensive but I think you'll agree has to offer because it's so
we've covered a lot of the basics and comprehensive but I think you'll agree
then some we've covered a lot of the basics and
so moving on in the next video we're then some
gonna make a start on checking out scene so moving on in the next video we're
builder now to date what we've done is gonna make a start on checking out scene
we've focused on using FXML and creating builder now to date what we've done is
that manually but scene builder does it we've focused on using FXML and creating
allows you to use sort of a that manually but scene builder does it
drag-and-drop principle to create screen allows you to use sort of a
design which is obviously going to be a drag-and-drop principle to create screen
lot easier than knowing design which is obviously going to be a
fxml so let's start looking at that in lot easier than knowing
the next video fxml so let's start looking at that in