0% found this document useful (0 votes)
15 views6 pages

OOP Lab 10 Assignment

Uploaded by

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

OOP Lab 10 Assignment

Uploaded by

Abdullah Afzal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

LAB WEEK 10

Task 1: You are tasked with creating a simple JavaFX application that displays a
personalized greeting message when a user enters their name and clicks a button.

A user opens the application and sees:

1. A TextField where they can type their name.


2. A Button labeled "Say Hello".
3. A Label that displays a greeting message.

When the user enters their name (e.g., "Alice") in the text field and clicks the "Say Hello"
button, the label updates to display "Hello, Alice!".

Requirements

1. Use JavaFX's TextField, Button, and Label components.


2. Implement an event handler for the button click to update the label with the greeting
message.
3. Initialize the application with an empty text field and a label that displays a default message
like "Welcome!".
Task 2: You are tasked with creating a JavaFX application that changes the background color
of the window when the user clicks a button.

The application starts with:

1. A window with a default white background.


2. A Button labeled "Change Color".

When the user clicks the "Change Color" button:

 The background color of the window changes to a random color.

Requirements

1. Use JavaFX's Button and Pane components.


2. Generate a random color using JavaFX's Color class.
3. Change the background color of the window's Pane each time the button is clicked.
Task 3:

You are tasked with creating a JavaFX application that increments a counter every time a
button is clicked.

The application starts with:

1. A Label displaying the number 0 (the counter's initial value).


2. A Button labeled "Increment".

Each time the user clicks the "Increment" button:

 The number displayed in the label increases by 1.

Requirements

1. Use JavaFX Label and Button components.


2. Update the label's text dynamically based on button clicks.
3. Keep the layout simple, with the label above the button.
Home Task 1: Create a simple JavaFX application to convert temperatures between Celsius
and Fahrenheit.
Task Description:

1. Layout:
 Add a Label for the title (e.g., "Temperature Converter").
 Add two TextField components for entering the temperature in Celsius and
Fahrenheit.
 Include two Buttons labeled "Convert to Fahrenheit" and "Convert to Celsius".
 Arrange the components using a VBox.
2. Functionality:
 Clicking "Convert to Fahrenheit" should calculate the Fahrenheit equivalent
and display it in the appropriate TextField.
 Clicking "Convert to Celsius" should calculate the Celsius equivalent and
display it.
3. Validation:
 Display an error message in a Label if the user enters invalid input.
4. Enhancement:
 Add tooltips to guide users on how to use the application.
Home Task 2: To-Do List Manager
Build a basic To-Do List application.
Task Description:
1. Layout:
 Add a TextField for entering a task.
 Include an "Add Task" button to add the task to a list.
 Use a ListView to display the tasks.
 Add a "Remove Selected Task" button to delete a selected task.
 Arrange components using a VBox.
2. Functionality:
 Clicking "Add Task" should add the entered task to the ListView.
 Clicking "Remove Selected Task" should delete the selected task from the ListView.
3. Enhancement:
 Add a confirmation dialog (Alert) before deleting a task.
Home Task 3: Simple Calculator
Scenario: Create a basic calculator application to perform addition, subtraction,
multiplication, and division.
Task Description:
1. Layout:
 Add two TextField components for number input.
 Include four Buttons for "+", "-", "*", and "/".
 Add a Label to display the result.
 Use an HBox for the buttons and a VBox for the overall layout.
2. Functionality:
 Clicking a button should perform the corresponding operation and display the result
in the Label.
 Handle division by zero with an error message in the Label.
3. Validation:
 Ensure both inputs are valid numbers before performing any operation.

You might also like