alright so let's so now add the code or
the setup here to delete a contact so alright so let's so now add the code or
like edit we will need a menu item but we the setup here to delete a contact so
don't need a dialogue that would be nice like edit we will need a menu item but we
if we display a message though asking don't need a dialogue that would be nice
the user to confirm the deletion we can if we display a message though asking
do that instead of using the dialog box the user to confirm the deletion we can
which we don't need by using an alert do that instead of using the dialog box
box so first let's go ahead and add the which we don't need by using an alert
menu code to the main.xml come box so first let's go ahead and add the
over here duplicate the line we have menu code to the main.xml come
for edit copy and paste that will change that over here duplicate the line we have
to delete then the delete method going for edit copy and paste that will change that
to change the name of that to be the on to delete then the delete method going
action should say to delete contact to change the name of that to be the on
okay look take a copy of that so action should say to delete contact
let go now to our okay look take a copy of that so
controller and we're going to change the code or let go now to our
add the code so that's we controller and we're going to change the code or
can delete the record so we're going to add the code so that's we
clean it up a little bit and the code.... can delete the record so we're going to
... clean it up a little bit and the code....
... ...
we're going to add another alert now ...
just as a confirmation before we go we're going to add another alert now
ahead and delete we do that with... just as a confirmation before we go
... ahead and delete we do that with...
... ...
the last thing we need ...
to do is just add our handling of the the last thing we need
the alert so optional button type.... to do is just add our handling of the
.... the alert so optional button type....
.... ....
code is very similar to the edit ....
contact handler except we don't have to code is very similar to the edit
show a dialogue so first we're ensuring contact handler except we don't have to
that a contact is selected then we show a dialogue so first we're ensuring
display the confirmation message and that a contact is selected then we
just to be user-friendly we've included display the confirmation message and
the selected contacts first and last just to be user-friendly we've included
name in the confirmation message if the the selected contacts first and last
user confirms the delete by clicking ok name in the confirmation message if the
we are calling the delete contact method with user confirms the delete by clicking ok
the selected contact and after the we are calling the delete contact method with
deletion is complete the selected contact and after the
we're going to we do save the deletion is complete
remaining contacts now since we're using we're going to we do save the
data binding the table will remaining contacts now since we're using
automatically update as it has in the data binding the table will
other scenarios so let's just run this automatically update as it has in the
to confirm that will work out so firstly other scenarios so let's just run this
in the case of not selecting contact to confirm that will work out so firstly
click on delete we get our please in the case of not selecting contact
select the contact you want to delete so click on delete we get our please
that's good select the contact you want to delete so
if i click on record here the second one that's good
click on delete are you sure you want to if i click on record here the second one
delete the selected contact brian click on delete are you sure you want to
johnson which matches the record click delete the selected contact brian
on cancel firstly to make sure that it johnson which matches the record click
hasn't updated to be a hundred percent on cancel firstly to make sure that it
sure will close the app down and run it hasn't updated to be a hundred percent
again to make sure that record still sure will close the app down and run it
exists because we press cancel still again to make sure that record still
there which is good so this time I'll exists because we press cancel still
click on the record click on edit click there which is good so this time I'll
on delete you sure you want to delete click on the record click on edit click
this time going to click on OK on delete you sure you want to delete
the records deleted as you can see there this time going to click on OK
and again shut down the to be sure their the records deleted as you can see there
aren't any issues and we got our three and again shut down the to be sure their
records aren't any issues and we got our three
alright so that's it we've completed our records
application now it would be nice if the alright so that's it we've completed our
table always filled the parent window application now it would be nice if the
depending on the contacts you added you table always filled the parent window
may find this an empty space to the depending on the contacts you added you
right of the columns and if we actually may find this an empty space to the
make this bigger you can see we end up right of the columns and if we actually
having a lot of space but also what we make this bigger you can see we end up
want to do here is that if we want to having a lot of space but also what we
make this smaller or larger we should want to do here is that if we want to
really be seeing that make this smaller or larger we should
table resizing just to basically fit the really be seeing that
window so that occupies the entire width table resizing just to basically fit the
so let's say add a bonus tip here to get window so that occupies the entire width
that to work so let's say add a bonus tip here to get
what you have to do is we have to set that to work
the column resize policy of the table what you have to do is we have to set
view so that the width of the columns the column resize policy of the table
will add up to the width of the view so that the width of the columns
tableview so right now the table view is will add up to the width of the
occupying the full width of the window tableview so right now the table view is
and we can see that in this case because occupying the full width of the window
of the alternating background color of and we can see that in this case because
the rows stretching across the entire of the alternating background color of
width of the window you can see between the rows stretching across the entire
as it is now but the column width width of the window you can see between
then selves aren't adding up to the width as it is now but the column width
of the tableview so in other words un then selves aren't adding up to the width
occupied space in the tableview so of the tableview so in other words un
let's go ahead and set the resize policy occupied space in the tableview so
to fix that we need to go back to our let's go ahead and set the resize policy
main . fxml file and just below to fix that we need to go back to our
where we have defined the tableview line main . fxml file and just below
after first definition we add where we have defined the tableview line
a column resize policies we put... after first definition we add
... a column resize policies we put...
... ...
let's just run this and then we'll go ...
back and talk about it notice already let's just run this and then we'll go
have things of space themselves a little back and talk about it notice already
bit more and make this a bigger we now got have things of space themselves a little
things expanding automatically to use up bit more and make this a bigger we now got
the amount of space we've got whether we things expanding automatically to use up
resize to make it larger or smaller the amount of space we've got whether we
that's obviously much better than what resize to make it larger or smaller
we had it so there are some other things that's obviously much better than what
you could certainly do to enhance this we had it so there are some other things
application example of a few things you you could certainly do to enhance this
could application example of a few things you
firstly allow the user to add more input could
about each contact or you could add the firstly allow the user to add more input
code to verify user input which will about each contact or you could add the
probably be something that i would code to verify user input which will
highly recommend you could look at probably be something that i would
adding cell factories to differentiate highly recommend you could look at
contacts in someway for example business adding cell factories to differentiate
vs personal etc allow the user to contacts in someway for example business
add a photo of each contact perhaps you vs personal etc allow the user to
can add a toolbar and if you're really add a photo of each contact perhaps you
feeling adventurous maybe add can add a toolbar and if you're really
error handling code to the load/store feeling adventurous maybe add
methods so that the user doesn't have to error handling code to the load/store
provide any notes for contact again you methods so that the user doesn't have to
saw what happened when I didn't provide provide any notes for contact again you
notes in the previous video I managed to saw what happened when I didn't provide
actually crash the application the notes in the previous video I managed to
application could be enhanced to be actually crash the application the
literally any way you could think of but application could be enhanced to be
you do know enough about javafx to learn literally any way you could think of but
and use what we didn't cover so i hope you do know enough about javafx to learn
you enjoyed this tour of javafx and and use what we didn't cover so i hope
the topics and videos that we've worked you enjoyed this tour of javafx and
through this section and that you know the topics and videos that we've worked
have some solid understanding of how to through this section and that you know
use Java fx to create Java have some solid understanding of how to
applications with rich user interfaces use Java fx to create Java
let's move on now to the next section of applications with rich user interfaces
this course let's move on now to the next section of