0% found this document useful (0 votes)
11 views3 pages

6-Adding Tasks Transcript

The document outlines the process of creating a method to add new tasks in a JavaFX application, including linking a text field and a button to the controller. It emphasizes the use of the FX decorator to connect UI elements, and explains how to add the text from the input field to a list view while ensuring that blank inputs are not added. Finally, it mentions the next step of implementing a function to delete tasks.

Uploaded by

ptttam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

6-Adding Tasks Transcript

The document outlines the process of creating a method to add new tasks in a JavaFX application, including linking a text field and a button to the controller. It emphasizes the use of the FX decorator to connect UI elements, and explains how to add the text from the input field to a list view while ensuring that blank inputs are not added. Finally, it mentions the next step of implementing a function to delete tasks.

Uploaded by

ptttam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Welcome back.

Let's not working with the head task functionality.


So let's go back to our controller Darch other
and I'll create another method.
So this is ah, regain public void.
Add new and I get it.
We need in action even from Java Fix not even and just call
it e. And in here what we want to do is get the text which is
present in this ad task a text field.
But right now, we don't have a ve to associate this text
field with our controller.
So let's do that.
Even used the FX emerald decorator, which again comes
from down my effects.
And Viva create.
Yeah, private instance Ralph next field.
And make sure that you import the one from Java effects
and not from Java.
Ada Beauty.
So I'm going to remove this and get it off text field, Tape
it again.
Next field in.
This needs to come from Java affects not seen, not control
Konate.
And let's call it new task The witness decorator.
He can associate instances that we have in the controller
class of it the you elements that we have in the FX Immel
file. So once you've done this and you save your changes
so good to save all.
And then if you go to your f XML file and select the task
Ah, text field, you've, ah, you will be able to drag and drop
down this menu here in ethics I d and select the variable
that he just declared.
So now you have created a connection between this you element
and this new task, uh, entity here, right?
So again, all you need to do is used the FX Immel decorator
and create a text field which needs to come from Java effects
don't seem not control and create he and object here off type
next feed.
And when you see it, your changes in the FX and the fire
in the text field Gord section, you will be able to see ah,
that you're able to actually select this FX I d.
With the drop down menu.
And if you look at the text off the FX symbol fire ah, you
will be able to see what's happening.
So in the text feud, you will see that FX I d has been added
and it's basically new task so you can make the changes here
directly.
Or you can use the scene better.
That's up to you.
I usually prefer the scene builder.
It seems easier.
Okay, now, in the add new task, the third we're going do P
a string and the discolored text.
And this would be new task.
It is, uh, this and could be here.
Thought get fixed.
And now, if you want, you can just rent out the biggest.
Okay? So again, let's save our changes and run the app.
No, uh, before within the f.
Actually, there's one problem.
We have created this link between this new task entity
and the U element for text field.
But we haven't actually created a link between the ad last
button and this method, so we'll need to do that as well.
So in the let's select the At Das Button and in the code
section for this button on action, people select had new dusk.
Okay, Now, via done, let's save the changes again.
And now we just need to run the app.
So no, If I add it, ask and click on the past button.
Then it's printed out the text off.
The task is printed out in the console.
All right, so that's great.
But that's not really what we want.
We want it to be added to the, um the list offer tasks
in list view.
So again, we can use FX Immel decorator to create a link
between the list view you element and, uh, an entity a listed
entity here in our controller.
So use FX, Emeril 58 list for you and even use.
Um think type.
Let's call it ask list and in ah, in our FX symbol Fire
weaken again.
Create a link between ah, this entity here and the list view.
So let's let's do that in a moment.
But we will also, uh, use this task list and get items
and add the text that we are extracting here from new mosque
to the items.
Okay, Now, let's see if this and go to our f xml file
and click on the list view, and we want to make sure that be
in the court section for list view, we drop down and select
the task list.
Okay, so let's save our changes.
And again, I'll just quickly go over what Peter's dead.
When the ad does, button is clicked we will get the text off
new task, which is the text field.
And that text will be printed out in your console.
No, if you want, you can remove this now.
Well, coming.
Get out.
And the task list, which is the list?
Few element off our you I we will get the items off the task
list and add text from the text field.
Do that list for you in their task list list view.
All right, so let's see more changes and run the Okay.
So I, uh, write something and kick on at dusk, and now you
can see that that's been added to the list view.
And if I wrote something else and again added it, it
will be added to the list view.
All right, now I need to add a couple of things here.
First of all, he shouldn't add any anything to our list
for you.
If the text, um, is just a blanks, drink eso If the text
field is left blank, then we don't want to add anything
at all.
So we will write a condition that if but next,
but we have extracted if this equals a blank string then we,
if this does not equal a blank list, didn't even do.
Yes, it is.
Add the text do list for you, and we will also set the new
task text to Blank.
But if this is a quick blank, then we don't need to add
anything to our list for you.
And we will simply print out a message saying Think no input.
Okay, so let's see our changes and run the court.
So just like before, I'm going to add something.
Click on at Bounce and that's added.
But notice that the text field was set do, um, a blanks drink.
And if I added a task without entering anything, then it will
just print out no input in the console, but it will not
actually add anything.
You, our mosques.
Okay, let's exit.
Great. So our add new task functionality is working correctly.
No, let's move on to the next task off are guided Project
and create a function which will let us delete tasks as well.

You might also like