Question
JAVA source code (JAVAFX) on eclipse please Tasks This lab has four parts: Create a window. Create two (2) text fields, a clickable button and
JAVA source code (JAVAFX) on eclipse please
Tasks
This lab has four parts:
- Create a window.
- Create two (2) text fields, a clickable button and a label/text object on the window.
- Create an event handler for entered text in the text fields.
- Create an event handler for the button to add the two text fields and display that in the label/text object.
Task 1 Window
Open a GUI project and create a window. The default code provided with the GUI project will accomplish this, so we will move on to the next topic.
Task 2 Create GUI Elements
Create two text fields, a button and a label and place them on the GUI window. The text fields will be able to take user input and display the text as they write it, similar to the email and password fields on a login page. The button was covered in the previous lab. Finally, the label will act as a piece of text on the window. It is different from the text fields since it cannot be directly written into by the user.
Task 3 The Text Field Event Handlers
The next thing to do is to add the event handlers to the text fields so that after the user writes some text into them and presses enter, we will save the input into the text fields. The process for this will be similar to the button event handler from the last lab.
Task 4 The Button Event Handler
Lastly, we will need to create an event handler for the button that takes the text from both of the text fields and adds them (the user should enter numbers, so this will be addition NOT concatenation) and displays the result of that addition by changing the text of the label to that result.
Some Sample Output:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started